Slow Performance on Duplicates Query?
I am running the following query to try and identify duplicates in my DB on a table
SELECT *
FROM
db.tablename x
JOIN db.tablename z
ON x.columnA = z.columnA
WHERE
x.columnB > z.columnB
However, it seems to be taking forever. i.e. just wondering whether this is a performance based issue or whether there is another开发者_JAVA百科 way I can write this which will work faster ?
Thanks
No obvious SQL issues.
- Don't do
select *
. - What are the column types? Make sure that you're comparing apples to apples - ints to ints, for instance, in your where clause.
- You're joining on a keyed column, right?
If you just need to test, you can fetch only a couple of hundred records. For example
SELECT top 100 *
FROM
db.tablename x
JOIN db.tablename z
ON x.columnA = z.columnA
WHERE
x.columnB > z.columnB
精彩评论