Bug #10088 Subqueries takes too much time to execute
Submitted: 22 Apr 2005 9:41 Modified: 24 May 2005 17:06
Reporter: Andrew Stukalenko Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.1.8 OS:Linux (Linux)
Assigned to: CPU Architecture:Any

[22 Apr 2005 9:41] Andrew Stukalenko
Description:
When executing queries with sub-queries like
---------------------------------------------------------------------------
SELECT 
   min(LOG.START_DATE), 
   count(TG.TG_ID) AS FM_COUNT
 FROM LOG
   LEFT JOIN TG on LOG.LOG_ID = TG.LOG_ID
   LEFT JOIN A_TYPE on TG.A_TYPE_ID = A_TYPE.A_TYPE_ID
 WHERE
   LOG.START_DATE >= '2005-04-01' AND LOG.STOP_DATE < '2005-04-03'    
   AND TG.TG_ID not in (
     SELECT DISTINCT TG.PARENT_ID FROM TG WHERE TG.PARENT_ID is not null
   )
   AND A_TYPE.NAME = 'build_analysis'
   AND TG.FAIL > 0
---------------------------------------------------------------------------

the execution of such queries takes lot of time (more than 10 minutes). While, executing the same query on the same database Windows MySQL 4.1.8-nt server, with the same configuration etc. takes less a second.

While running reports: 

| Id   | User| Host       | db  | Command | Time| State                      | Info
+----+-----+----------+----+----------+-----+---------------------+----------
|1211| xxx  | xxx:1096 | xxx | Query      | 867 | Copying to tmp table | select min(LOG.START_DATE), count(TG.TG_ID) AS FM_COUNT, FROM LOG LEFT JO |

How to repeat:
Just use any sub-query with 4.1.8-unix
[24 Apr 2005 17:06] Hartmut Holzgraefe
Can you please upload a dump that allows testing of the posted query?
[24 May 2005 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".