List:General Discussion« Previous MessageNext Message »
From:Augey Mikus Date:May 8 2002 3:39pm
Subject:Re: Unnecessarily long query time
View as plain text  
Thanks.  I'll try to rewrite it.

Victoria Reznichenko wrote:

>Augey,
>Wednesday, May 08, 2002, 5:10:27 PM, you wrote:
>
>AM> On one of my MySQL servers (Dell PowerEdge 800Mhz w/ 512MB RAM), I have 
>AM> a couple tables that have about 3 million records in each. However some 
>AM> of the records in the tables are duplicates of each other. Here is a 
>AM> query that should return the number of unique records for both tables:
>
>AM> select count(*) from table1,table2 where table1.value != table2.value;
>
>AM> However, this query has been running for more than 40 hours and still 
>AM> has not finished.  Is this normal?
>
>May be :) This is a very "hard" SQL statement. You will get in 
>result set full cartesian product of non-equal rows in your both tables, 
>i.e. (couple of millions rows)x(couple of millions rows) = ~number with 12 zeros :)
>
>Re-write your statement with JOIN, look at:
>         http://www.mysql.com/doc/J/O/JOIN.html
>
>AM> Thanks,
>AM> Augey
>
>
>
>
>
>  
>



Thread
Unnecessarily long query timeAugey Mikus8 May
  • Re: Unnecessarily long query timeFournier Jocelyn [Presence-PC]8 May
  • Re: Unnecessarily long query timeAugey Mikus8 May
  • Re: Unnecessarily long query timeVictoria Reznichenko8 May
  • Re: Unnecessarily long query timeFournier Jocelyn [Presence-PC]8 May
  • Re: Unnecessarily long query timeAugey Mikus8 May