Is there a performance penalty for creating new Dexie instances on every use? #1656
-
Here to ask a quick question and hoping someone already has this knowledge before I start performing my own tests. Currently in our prototype, in Obviously, this is not optimal and we will store/cache the instances in the future but we're short on time - so I'd like to know whether doing it the way we're doing it here is hurting performance so I know whether improving this immediately should be a high priority. Maybe there is some overhead for creating a new instance, or a cache we're missing out on? Does anyone have knowledge whether creating new instances on every access is having a noticable or major effect on query latency/performance? Thanks :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I advice you to prioritize improving it as soon as possible because each Dexie will spend some time opening the database. Also, this might leak resources and memory as databases aren't properly closed. Suggesion would be to have a static Map between customerId and Dexie instances, a helper function to get a Dexie instance based on customerId, that get it from that cache instead of creating a new Dexie each time. |
Beta Was this translation helpful? Give feedback.
I advice you to prioritize improving it as soon as possible because each Dexie will spend some time opening the database. Also, this might leak resources and memory as databases aren't properly closed.
Suggesion would be to have a static Map between customerId and Dexie instances, a helper function to get a Dexie instance based on customerId, that get it from that cache instead of creating a new Dexie each time.