This select query runs on our servers, and runs for a few days without ceasing, causing the CPU to run between 90%-100%. I ran an estimated execution plan against it, and 80% of the cost is from an Index Seek, and about 20% is from the sort. I did a rebuild on the Index, and updated the stats, but the query still causes the CPU's to spike and continues to run, even if I specify to only grab the top 2 records.
Anyone have any thoughts on this? The FROM clause is a bit different, I'm used to seeing Inner/Outer joins, but not sure what straight comma's mean. Don't know if that is playing into it somehow.
Any help is greatly appreciated!
-Ovatvvon :-Q
Anyone have any thoughts on this? The FROM clause is a bit different, I'm used to seeing Inner/Outer joins, but not sure what straight comma's mean. Don't know if that is playing into it somehow.
Any help is greatly appreciated!
Code:
select l_name, f_name, users.EMPLOYEE_ID, min(extn) extn, min(bill_level_code) cost_ctr1, max(bill_level_code) cost_ctr2
from users, users_extn, extn, bill_detail, bill_level
where users.user_id = bill_detail.user_id and users_extn.extn_id = extn.extn_id and bill_detail.bill_level_id = bill_level.bill_level_id and bill_detail.bill_level_id != 0
group by l_name, f_name, employee_id having min(bill_level_code) != max (bill_level_code) order by l_name, f_name
-Ovatvvon :-Q