SQL Server Performance

Slow Query

Discussion in 'General Developer Questions' started by kate_for_u, Jul 8, 2003.

  1. kate_for_u New Member

    Hi all

    Please look at the The query below

    select intAuditId,txtSchAuditeeEmpNo,txtSchAud1EmpNo,txtSchAud2EmpNo,txtSchSbAudEmpNo,txtProjectCode,dtScheduled
    from Accuser
    where datepart(month,dtScheduled) = 7
    and
    datepart(year,dtScheduled) = 2003
    and
    flgStatus = 'T'


    This is running very slow . There is only one clustered index on intAuditId.
    Non Clustered Index on flgStatus will not help because selectivity is poor
    Can the performance improve if I merge the datepart together for month and year??
    Which function do I use ?
    [?]
  2. gaurav_bindlish New Member

    In this query, the clustered index on the intAuditId column will not help. Try writing the query like
    select intAuditId,txtSchAuditeeEmpNo,txtSchAud1EmpNo,txtSchAud2EmpNo,txtSchSbAudEmpNo,txtProjectCode,dtScheduled
    from Accuser
    where dtScheduled >= '07/01/2003'
    and
    dtScheduled <= '07/31/2003'
    and
    flgStatus = 'T'
    and create non-clustered index on dtScheduled.

    See if this helps

    Gaurav
  3. kate_for_u New Member

    No Index on date column did not help
  4. gaurav_bindlish New Member

    Did u use this query? BTW how many rows in the table are being retured? And how many total rows are present?

    Gaurav

Share This Page