Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
gjtheemskerk
Starting Member
4 Posts |
Posted - 2013-02-12 : 06:24:50
|
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 tableindex used is PK clustered indexmany many thanks! |
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2013-02-12 : 07:36:58
|
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? |
|
|
gjtheemskerk
Starting Member
4 Posts |
Posted - 2013-02-12 : 07:53:34
|
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! |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2013-02-12 : 08:20:51
|
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. |
|
|
gjtheemskerk
Starting Member
4 Posts |
Posted - 2013-02-12 : 08:31:07
|
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? |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2013-02-12 : 10:36:52
|
Is your clustered index on comp_no or is there another index on comp_no? |
|
|
gjtheemskerk
Starting Member
4 Posts |
Posted - 2013-02-15 : 06:49:46
|
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! |
|
|
|
|
|
|
|