List:General Discussion« Previous MessageNext Message »
From:Victoria Reznichenko Date:May 8 2002 2:44pm
Subject:Re: Unnecessarily long query time
View as plain text  
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





-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Victoria Reznichenko
 / /|_/ / // /\ \/ /_/ / /__   Victoria.Reznichenko@stripped
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
       <___/   www.mysql.com



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