简体   繁体   中英

pre-compiled view not affecting performance

EDIT :

This question is not about compiled queries, it is about generating the EF database view at compile time.

From the ADO.NET team blog: Exploring the Performance of the ADO.NET Entity Framework - Part 1 :

View Generation 56%– A big part of creating an abstracted view of the database is providing the actual view for queries and updates in the store's native language. During this step, the store views are created. The good news is there is a way of making view generation part of the build process so that this step can be avoided at run time.


The first database call in my web app takes about 2.5 seconds instead of ~30 ms for subsequent identical calls.

I generated a precompiled view source file using the T4 template from the ADO.NET team blog , but it has made no detectable difference.

The T4 template takes about 2.5 seconds to run and the generated code compiles.

What am I missing?

Fixed it!

The Generated View derived from EntityViewContainer must be in the assembly that contains the STOs Self-Tracking Objects, not the one that contains the edmx model.

Your first call to your application after a build, the web server will have unloaded the application, and the first call "starts" the application again, and everything that is associated with that. This has nothing to do with pre-compiled views. Therefore, the first call will always take longer as the application is loaded.

Incidentally, the same thing will happen on your production server. An idle worker-pool might well unload your application, and the next call will load the application again, taking significantly longer to perform than usual requests.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM