Breeze importEntities

狂风中的少年 提交于 2019-12-12 01:26:58

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!