问题
When my application loads, I am exporting few breeze entities and storing those in local cache so that later when I have to make use of those entities again, I import them back from local storage and execute the query locally.
There is one entity that has 84389 rows. I have noticed that the importEntites take longer to execute for this entity. Is there a way I can speed up this ?
var entities = manager.getEntities('Client');
var exportedEntity = manager.exportEntities(entities, { includeMetadata: false });
I am storing exportedEntity in cache.
I am importing the above exportedEntity into entitymanager after fetching from cache.
entityManager.importEntities(exportedEntity);
The above statement takes longer for the Client entity. The client has 80K rows in table. I am not sure if that reduces the execution speed for importEntities method. I am also executing query locally after the entity is imported.
回答1:
I think you mean that you have an EntityType, Client
, with 84k rows/entities.
That's a lot of objects. I would reconsider whether that data should be treated as rich Breeze entities or if they should be held in a simpler, more compact form as data objects. I'm leaning strongly to the latter, especially if they are read-only. There is less benefit to representing read-only data as entities and, at these volumes, bad performance and memory usage are more likely.
Remember that not all data have to be entities and Breeze is happy to fetch a mix of entity and raw data. Hybrid apps are quite common.
If you still want to explore treating them as entities, you might try the following export command which outputs all entities of a given type as JSON:
var exported = manager.exportEntities('Client', {asString:false, includeMetadata:false});
The result can be imported as before.
var imported = manager.importEntities(exported);
This may improve export and import speed (or not).
You don't have to query locally afterward. All the imported entities are in imported.entities
.
来源:https://stackoverflow.com/questions/28677833/breeze-importentities