1
select a.col1,a.col2,count(b.col1) as cnt 
from table1 a,table2 b 
where b.col2 between a.col1 and a.col2 
group by a.col1,a.col2

The above query is taking 5 minutes in SQL Server 2008 r2 and taking 100% cpu usage, any idea to tune the query?

There are indexes on table1 & table2 columns.

krokodilko
  • 35,300
  • 7
  • 55
  • 79
Pavithra
  • 11
  • 1

0 Answers0