开发者

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.

  1. Don't do select *.
  2. What are the column types? Make sure that you're comparing apples to apples - ints to ints, for instance, in your where clause.
  3. 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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜