![]() |
More Efficient Query Needed
Hi All
Does anyone have an idea how to run this query... Code:
The sub query option seems to be taking ages to run. Is there a more efficient query that does the same thing? Thanks in advance for any help. |
SELECT [ColumnName]
FROM [TableName] GROUP BY [ColumnName] <= Not needed because that is the only thing your getting HAVING COUNT(*) > 1 <= This makes no sense to me because count() tells you the number of rows. Do you mean where the value of the ColumnName column is large then 1? |
More efficient query
Sorry, it would help if I explained what I'm trying to do!
The query is supposed to search a column (name) for duplicate values and then return all data in the table which has duplicate values in that column Any ideas? |
Nope, I think you have it right.
Though doing it like this *MIGHT* be more efficient: Code:
SELECT T1.*Code:
SELECT T1.* |
It will, of course, make a *HUGE* difference if column is indexed.
|
Magic!
I ran the query on an 80MB table and it returned in 6.5 minutes. I then made the column concerned an index, ran the same query and it returned in 7.6 seconds! Bit of a difference:thumbsup: Thanks a million for your help, got a critical meeting tomorrow morning and you'll make me look like superman.:D |
LOL! The cardinal rule of database design: When it's slow, index it.
|
| All times are GMT +1. The time now is 11:52 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.