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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Parallelism SP tuning

Author  Topic 

sqlcoolteam
Starting Member

1 Post

Posted - 2009-10-28 : 05:53:09
Hi there

This simple query below kills our server performance bcos this logic is used in lot of our SPs
if there is a better way pls help.

@sectionID <=0
OR a.section_id = @sectionID


this above code does parallelism but if i comment 1 line it dosent

--@sectionID <=0 OR
a.section_id = @sectionID

i have a non-clustered index already on section_id
there are 494569 records in that table

Cheers

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-10-28 : 07:24:32
@sectionID is optional? is it the only optional paramater?

can try reversing the order:

a.section_id = @sectionID
OR @sectionID <=0

may be better to make 2 SPs, one for each condition if it's the only optional param. obviously, @sectionID <=0 will force a table scan.

would like to see the entire query...if you're joining then you may be processing a lot more than the # of records you posted. also, set statistics_io on, and look at the output
Go to Top of Page
   

- Advertisement -