Search code examples
javascriptasp.net.netentity-frameworkbreeze

Loading metadata with breeze is slow


I'm using breeze to load some data from a remote SQL Server database in a MVC 4 application. The database has around 40 entities. The loading of metadata with breeze takes a lot of time: somewhere between 14s and 35 s even though the size is not that big: ~ 600 kb.

After the metadata is loaded the entities are fetched much faster. For example an entity of 2.5 Mb was loaded in 2.5s.

https://www.dropbox.com/s/n8eqv5ezqr1qqlp/loading.png

My question is:

Is there a reason why this loading is that slow and what would be a way to reduce the time of loading?


Solution

  • I rarely ask the server for metadata once I get going. I quickly export the metadata from an EntityManager's metadata store and dump that into a JavaScript file as a global variable. I include it with my other scripts on my index.html. I load this var into my manager's metadateStore on launch.

    I get progressively more sophisticated over time, regenerating it automatically when the server starts, serializing and storing it in browser local storage, etc. Once you realize that metadata is just a JS object, you hold the key to endless. Cleverness.