Bug #32665 Query with dependent subquery is too slow
| Submitted: | 23 Nov 2007 16:26 | Modified: | 23 Nov 2010 3:32 |
|---|---|---|---|
| Reporter: | adrian drumea | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
| Version: | 5.1.22-rc-Debian_1-log | OS: | Any |
| Assigned to: | Sergey Petrunya | CPU Architecture: | Any |
| Tags: | dependent subquery, IN, slow, subquery benchmark | ||
[23 Nov 2007 16:26]
adrian drumea
[23 Nov 2007 16:47]
Valeriy Kravchuk
Thank you for a problem report. This is a known optimizer's deficiency that will be fixed in MySQL 6.0.x.
[28 Dec 2008 0:05]
Sergey Petrunya
Confirm, should be handled by new subquery optimizations in MySQL 6.0. The query is uncorrelated, so WL#3985 code may bring extra benefits.
[28 Dec 2008 15:00]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/62387 2758 Sergey Petrunia 2008-12-28 BUG#32665: Query with dependent subquery is too slow - Testcase (the code is subquery optimization WLs)
[11 Jan 2009 14:51]
Bugs System
Pushed into 6.0.10-alpha (revid:sergefp@mysql.com-20090110105650-he9xy4221tbn5y70) (version source revid:sergefp@mysql.com-20090110105650-he9xy4221tbn5y70) (merge vers: 6.0.10-alpha) (pib:6)
[13 Jan 2009 1:51]
Paul DuBois
Noted in 6.0.10 changelog. Queries with dependent subqueries were slow.
[16 Aug 2010 6:37]
Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100816062819-bluwgdq8q4xysmlg) (version source revid:alik@sun.com-20100816062612-enatdwnv809iw3s9) (pib:20)
[13 Nov 2010 16:24]
Bugs System
Pushed into mysql-trunk 5.6.99-m5 (revid:alexander.nozdrin@oracle.com-20101113155825-czmva9kg4n31anmu) (version source revid:vasil.dimov@oracle.com-20100629074804-359l9m9gniauxr94) (merge vers: 5.6.99-m4) (pib:21)
[23 Nov 2010 3:32]
Paul DuBois
Bug does not appear in any released 5.6.x version. No 5.6.1 changelog entry needed.
[2 Dec 2011 10:30]
Asad ahmed
I have MySQL Server 5.5 and my sub query is very very very slow where as the same query takes hardly 1 second in SQL server 2005.My Subquery is as follows: select articlenumber from temp_tag where articlenumber not in ( select distinct cont from temp_tag where heading is not null and heading <> '' and publishdate='2011-10-20' and type = 'story' and cont <> '0') I am stuck :( please help...
[2 Dec 2011 12:42]
Guilhem Bichot
To Ahmed: "distinct" is useless in this query. Try one of those queries, which could be equivalent to yours: - without distinct: select articlenumber from temp_tag where articlenumber not in ( select cont from temp_tag where heading is not null and heading <> '' and publishdate='2011-10-20' and type = 'story' and cont <> '0') - without subquery: select outer.articlenumber from temp_tag AS outer LEFT JOIN temp_tag AS inner ON outer.articlenumber=inner.cont and inner.heading is not null and inner.heading <> '' and inner.publishdate='2011-10-20' and inner.type = 'story' and inner.cont <> '0' WHERE inner.heading IS NULL (search for "You can use this fact to find rows in a table that have no counterpart in another table" in http://dev.mysql.com/doc/refman/5.6/en/join.html ).
[2 Dec 2011 13:26]
Asad ahmed
@Guilhem this is also taking same time.
[2 Dec 2011 14:01]
Guilhem Bichot
To Ahmed: then I have no idea. Maybe tables are missing some index. You should look at EXPLAIN output. Also you can ask questions on forums: http://forums.mysql.com/
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.045 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.