Quantcast
Channel: Forum SQL Server Database Engine
Viewing all articles
Browse latest Browse all 15889

complex query resulting in very slow compilation, how to improve it?

$
0
0

Hi,

we have an application which use dynamically generated queries, and 1 of these query is very complex and very slow to compile (up to 60sec!!!!)

currently we cant change the application (apparently the java guys found this complicated... ) and the query is executed multiple times.

this results in a lock escalation in SQL Server to wait for the previous compilation to finish...

what can I do to reduce the compilation time?

I do a test by moving the query into a SP, here the compilation time is reduced to 20 to 25sec, but SQL is able to correctly keep the plan in cache and my small tests demonstrate a big win...

so until I can convince the dev team to change the code... I'm looking for alternative options...

thanks.


Viewing all articles
Browse latest Browse all 15889

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>