DOWNLOAD THE CODE:
Download the Code 44843.zip

The query in Listing 1 returns a result set in 35 seconds when I run it on database1 but returns the result set in 19 seconds on database2. The databases are structurally identical and reside on the same server. Database1 has only 10,000 rows more than database2. The query execution plans are almost identical, but on database2, the query uses a parallel plan; hence, the speedier execution time. Unfortunately, I have a limited ability to make structural changes to the queries or indexes, and when I run the query on database1, it often times out. Can I force SQL Server to use a parallel plan on database1?

No. You could change the cost threshold for parallelism option to 0, which would let SQL Server consider a parallel plan for a plan with a zero cost, but I don't know of a way to force SQL Server to pick a parallel plan over a serial one. Also, although you're limited in how much you can change the queries, you should realize that a search argument, such as OrgName LIKE '%SPOTS%', can't be effectively indexed because the leftmost part of the string is a wildcard. In this situation, you might get substantially better performance on both databases by using Full Text Search instead of a LIKE operator.

End of Article




You must log on before posting a comment.

If you don't have a username & password, please register now.

Reader Comments

Bryan,

Your response about OrgName like '%SPOT%' is on query tuning, not on how to get the query to run in paralllel processing. I am still left hungry about knowing more. Running queries in parallel is always better for us since we have an 8-way processor. Would setting cost threshold for parallelism option to 0 will allow us to use all processors, thus improving response time? Developers in house came up with a solution which breaks down the query in 10 little queries, can collates the 10 result sets into a single one. I would rather have SQL run one query, do the parallel processing, and return to me one result set. Would it be the way to go, to set the cost threshold for parallelism and hope SQL picks out the optimum plan?

Thanks for the good work.

nonicknameplease.

nonicknameplease

Article Rating 1 out of 5