The query is just... select name, max(date) from myTable group by name
myTable had a clustered index PK, also non-clustered indexes on name and date.
There are approx 1,000,000 rows and there are only 3 distinct names.
This takes 10-15 secs to execute, even running directly on the server.
Server trace says duration = 100, reads = 100
Profiler says CPU=20000, reads = 20000, duration = 10000
What on earth is going on ! ![]()

Why is this slow?
Mike Price
zyunique
Mike H B
Is it on SQL 2000 or 2005 How is the Clustered index defined For this case, it will be useless if it is on name column only as it contains only 3 distinct values.
-- runt the following in Query Analyzer (for 2000) or management Studio (for 2005), it will show IO + CPU time for compile and execution
SET statistics IO ON
go
your query here
go
SET statistics IO OFF
go
-Shus
drpavan
Elina
--
Adam Machanic
Pro SQL Server 2005, available now
http://www..apress.com/book/bookDisplay.html bID=457
--
Altunin Yuri
--
Adam Machanic
Pro SQL Server 2005, available now
http://www..apress.com/book/bookDisplay.html bID=457
--