SQL Server Performance

Performance Comparison of Queries...

Discussion in 'SQL Server 2005 T-SQL Performance Tuning' started by Ritu, Mar 31, 2008.

  1. Ritu New Member

    Hi ,
    I have table on which i have search records on differnent combinations.
    Select Distinct ID from table1 where (C1 = 23 OR (C1=0 AND C3='Y') OR (C3=5 AND C5=9 AND C6=9))
    So it is going for full table scan.
    I have changed it to
    Select ID from table1 where C1=23
    Union
    Select ID from table1 where C1=0 AND C3='Y'
    Union
    Select ID from table1 where (C3=5 AND C5=9 AND C6=9)
    And I have created Indexes to support above.
    1) Which Query will give me better results when Data in the tables are high ?
    2) Which is better approach , if any other please give ur thoughts.
    FYI, Second approach has increased the Scancount multiple times but there is not much diff in Logical Reads.
    Regards,
    Avnish Kumar
  2. FrankKalis Moderator

    Actually only you can test this in your environment. [:)]

Share This Page