samedi 8 août 2015

First SQLite query slow with Entity Framework 6

I've builded a small C# application that access to a simple SQLite database located in the same folder. The application is not very complex and the DB is very simple (7 tables with 4-5 columns each and a predicted operative volume of data of less than 1000 records).

To speed up development i decided to use Entity Framework 6 code-first (autogenerated by EF power tools) and it works like a charme on my mid-level development PC (Intel i5-2400@3.10Ghz, 8Gb RAM, 256Gb Samsung PRO SSD, Win10 x64). The first access to the context takes place in application load, and it takes "only" an acceptable 2266mS, 130mS to create my DbContext object and 2126mS to execute the first Select() query over a table that contains 3 records.

Unfortunately on the production PC (that's a Samsung 9 lite, quad-core 1.4Ghz, 4Gb ram, 64Gb SSD, Win8.1 x64), the first access takes a ridiculousy 24300mS, 1200mS to create my DbContext and 23054mS to execute the same Select() query. After the fist load, even the more complex queries, takes a few milliseconds. 24 seconds to load my application is not acceptable, thus i began to find some fix on web.

All the people that notifies slowness in their app's first SQLite db access, uses DbContext of discrete dimension (about 50~100 entities) and so compiled LINQ queries and pre-compiled views makes sense in here, but i don't think is my case. As i said earlier, on my developement PC it takes an acceptable time...I don't want to spend my time in introducing complexity for a simple CRUD application over a 7 table DB.

This is the first time that i use SQLite with EF. Maybe i'm doing something wrong. Usually i use it against SQLServer and i have never had any performance problems...

Someone can give me a few advice? Thanks

Aucun commentaire:

Enregistrer un commentaire