SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Parallelism not used with clustered index
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

gjtheemskerk
Starting Member

Netherlands
4 Posts

Posted - 02/12/2013 :  06:24:50  Show Profile  Reply with Quote
A good day all,

Can someone help me understand why parallelism is not used with the following query?

exec sp_executesql N'SELECT * FROM supplier
WHERE (1=1)
AND (comp_no IN (@P1,@P2,@P3))',N'@P1 nvarchar(20),@P2 nvarchar(20),@P3 nvarchar(20)',N'1400',N'1500',N'1300'

- server has 4 cores
- sp_configure has max parallelism set to 0
- parallelism is used with other queries on same table

index used is PK clustered index

many many thanks!

RickD
Slow But Sure Yak Herding Master

United Kingdom
3608 Posts

Posted - 02/12/2013 :  07:36:58  Show Profile  Reply with Quote
The engine probably deems it faster to use the clustered index than to use any parrellel processing in regards to this particular query (maybe due to the time it can take to gather the threads back together sometimes).

How many records are returned?
Why do you want SQL to use parrellelism for this query?
Go to Top of Page

gjtheemskerk
Starting Member

Netherlands
4 Posts

Posted - 02/12/2013 :  07:53:34  Show Profile  Reply with Quote
Hi! thanks for quick reply :)

# of rows returned = 38.713 and it takes 3 seconds to execute.

i was wondering if this could be faster if the work is divided among multiple workers.

greetings from Amsterdam!
Go to Top of Page

nigelrivett
Flowing Fount of Yak Knowledge

United Kingdom
3383 Posts

Posted - 02/12/2013 :  08:20:51  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
Try hard coding the query and see whathappens.
Do you really need all the columns returned.
Also try building a string for the query rather than using parameters.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

gjtheemskerk
Starting Member

Netherlands
4 Posts

Posted - 02/12/2013 :  08:31:07  Show Profile  Reply with Quote
thanks again ;) the query is hard coded in an application so I cannot change it. also, all the columns need to be returned yes. when i rewrite the query so that it does not uses the parameters, there is no change in execution time. I guess this is all the performance i can get out of this?
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

United Kingdom
3608 Posts

Posted - 02/12/2013 :  10:36:52  Show Profile  Reply with Quote
Is your clustered index on comp_no or is there another index on comp_no?
Go to Top of Page

gjtheemskerk
Starting Member

Netherlands
4 Posts

Posted - 02/15/2013 :  06:49:46  Show Profile  Reply with Quote
Hello Rick,

The clustered index is on comp_no and supplier_num. supplier_num being the PK.

no other indexes on comp_no are active. i have also tried to rebuild the clustered index with only the supplier_num column indexed. But that does not give me parallelism either.

thanks!



Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000