>I have a SQL Server 6.5 query that is based on a date range. For example, if I put in 03/01/1999 and 03/15/1999 I get results quickly. If I put in 03/01/1999 and 03/31/1999 it takes a very long time. Any ideas?
>
>The code:
>
>SELECT id, first, middle, last, type, expdt, fromdt, thrudt, 9999.99 as dues, 999 as instal, 9999 as months from master where group = 'Member' and delet <> 1 and exprdt >= m.expdt1 and expdt <= expdt2 and id not in (select dueid from dues where period = ?m.period or (duetype = 'LIFE' and thrudt = '12/31/9999')) order by last
SQL Server may be employing a table lock because of the larger date range and because of the number of pages required to fulfil the query.
You could try a couple of things. Use a clustered index for expdt. It could be a problem with statistics that are used by the query optimizer. Try updating statistics. You might even try rearranging your where clause. try putting the conditions that have the fewest records at the beginning.
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement