This is a migrated thread and some comments may be shown as answers.

Compiled LINQ query cache?

9 Answers 124 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kendall Bennett
Top achievements
Rank 2
Kendall Bennett asked on 04 Jul 2011, 08:49 PM
Is there any support (or planned support) for automatically caching the generated queries inside OpenAccess? This is a new feature recently added to Entity Framework June 2011 CTP, which can speed up performance for queries used regularly as it will avoid the need to recompile to SQL for every LINQ query again.

I checked the documentation and I did not see anything that indicated that this is supported in OpenAccess?

9 Answers, 1 is accepted

Sort by
0
Thomas
Telerik team
answered on 06 Jul 2011, 10:12 AM
Hello Kendall Bennett,

OpenAccess always caches the compiled LINQ query statements for later use if the same LINQ query (with different parameters though) is executed again; we do that internally, and the application does not need to be changed / made aware of the caching.

Greetings,
Thomas
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Kendall Bennett
Top achievements
Rank 2
answered on 06 Jul 2011, 04:08 PM
That is great news. Is there any support for manually compiling a query for something that is used regularly?
0
Thomas
Telerik team
answered on 07 Jul 2011, 09:30 AM
Hi Kendall Bennett,

no, there is no manual Compile() call, it would be a no-op. All LINQ queries get compiled+cached automatically. 

Kind regards,
Thomas
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Kendall Bennett
Top achievements
Rank 2
answered on 19 Jul 2011, 12:59 AM
I can see this is enabled in the back end settings for the model, but the documentation is very scarce on this matter. The default setting for this in the back end is 0, which I assume means it is turned off by default?

The problem is I have no idea what are considered 'reasonable' values to put in here? The values I assume indicates how many queries will be cached in the query cache, but what is a reasonable setting for this value? 10? 100? 1000? Does anyone have any good suggestions for a reasonable number to put in here that will give good performance but not eat up tons of memory?
0
Thomas
Telerik team
answered on 19 Jul 2011, 01:10 PM
Hi Kendall Bennett,

the compiled (LINQ/OQL=>SQL) query cache cannot be configured or turned off. What can be configured is the compiled query _results_ cache as a part of the second level cache. The 'reasonable' number that you can use to limit this cache really depends on the chosen model, as well as the amount of data and the available memory.

Regards,
Thomas
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Kendall Bennett
Top achievements
Rank 2
answered on 19 Jul 2011, 03:44 PM
Are you sure that is correct? There value I am talking about is the value listed on the 'Runtime Configuration' page of the model settings in the designer, as shown in this picture:

http://www.telerik.com/help/openaccess-orm/images/1DevEnvironment-Wizards-Model-Designer-ModelSettings-Backend-010.png

It is documented on this page:

http://www.telerik.com/help/openaccess-orm/developemnt-environment-wizards-dialogs-model-tools-designer-model-settings-backend-settings.html

and the documentation for the 'Compiled Query Cache' option says the following;

Compiled Query Cache - specifies whether to cache compiled queries.

The settings you are talking about are in the 2nd Level Cache settings dialog box, which controls where query results are cached, and how many of them are cached.

So I am pretty sure I am right in that the setting I am talking about controls how the compiled query cache is configured, and by default is set to a value of 0. I have assumed 0 means the cache is turned off, and that setting it to a non-zero value will enable it and allocate that many slots for the compiled query cache. All I really need to know now is what is considered a good value for this?
0
Thomas
Telerik team
answered on 20 Jul 2011, 10:14 AM
Hi Kendall Bennett,

 I'm really sorry, I've given you a wrong answer (I never play with this setting). The default value is 0, which is internally translated to the default size of 1000. Negative numbers will lead to a setting of 1000 as well, so the smallest value that is settable by the user is 1. 
Again, I never change that value, it just works. The only reason to increase the value would be that you have more than 1000 different queries for which you need to store the compiled query information. This would be visible only by looking at the execution log, and we should add a metric so that the removal of compiled queries would be more visible. I will file an entry for that.

Greetings,
Thomas
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Kendall Bennett
Top achievements
Rank 2
answered on 20 Jul 2011, 07:49 PM
Ok, thank kind of makes sense with my findings as I found no performance improvement changing this value from 0. In fact when I set the value to 1000 (so I assume 2000 total entries in the cache), my code ran slightly slower.

It would be nice if this was better documented :)
0
Zoran
Telerik team
answered on 25 Jul 2011, 05:28 PM
Hi Kendall Bennett,

 Thanks for the note. We will ad this information to the documentation with the highest priority.

Best wishes,
Zoran
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
General Discussions
Asked by
Kendall Bennett
Top achievements
Rank 2
Answers by
Thomas
Telerik team
Kendall Bennett
Top achievements
Rank 2
Zoran
Telerik team
Share this question
or