I have a question about adding index to improve the performance of the query. I have a big table called c and relatively
small table called d. The number of rows in c is several handred million. I have a query which is used by many applications
to get data from these two tables, the performance of this query is horrible, sometimes it uses CPU for as long as 20
SELECT d.d1, COUNT(c.c3)
FROM c, d
WHERE d.d1 = c.c2
AND c.c1 > '06/01/03'
AND c.c1 < '06/05/03'
AND DATEPART( hour, c.c1 ) >= 2
AND DATEPART( hour, c.c1 ) <= 10
AND d.d2 = 1
GROUP BY d.d1
c table ( The primary key of this table is the combination of c1, c2, c3 and another varchar(20) column)
d1 int (primary key)
I wonder if there is a way to improve the performance of this query by adding a clustered index on (c1, c2, c3) and another
clustered index on d1
Thanks a lot!
Edited by - zxmgh on 09/13/2003 4:00:04 PM