Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 12554

Optimization

$
0
0

Hello Sirs:

I’m longing for the days of the SQL Server 6.x when the Execution Plans were very readable and the Query Hints were taken as written. When the optimizer had problems with a complicated query, the Query Hints where always an available turn around. Now in SQL Server 2012 I have again a very complicated Query with recursive views involved. The same Query responds almost instantly in certain conditions and takes up to 20 minutes in others. (I do not paste de Query because it is very large.)

For example if I change only one line of the query:

“WHERE idProject = 25 /* the id 25 represents a very large project with 20,000 entries, and a very acceptable response time */”

to

“WHERE idProject = 10 /* it’s a small project with 2,000 entries, and a very nasty response time */”

Curiously the optimizer takes the right decisions on the big projects and takes the bad decisions on the smaller ones.

I want to take the Execution Plan from the context in which the Query is very efficient and force the Optimizer to use that one in every case. I’ve taken months researching in the documentation, and I found that it’s possible, but I haven’t found how. Can you help me please?

Juan


JuanGN


Viewing all articles
Browse latest Browse all 12554

Trending Articles



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