Bug #20932 | optimizer/statistics takes 20 times (and more) as long as actual query execution | ||
---|---|---|---|
Submitted: | 9 Jul 2006 17:10 | Modified: | 17 Aug 2007 18:43 |
Reporter: | Martin Friebe (Gold Quality Contributor) (OCA) | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S4 (Feature request) |
Version: | 5.0.25-BK, 4.1.20 and 5.0.22 | OS: | Linux (Linux, freebsd) |
Assigned to: | CPU Architecture: | Any | |
Tags: | qc |
[9 Jul 2006 17:10]
Martin Friebe
[23 Jul 2006 13:19]
Valeriy Kravchuk
Verified just as described with 5.0.25-BK on Linux. Explain (without IGNORE INDEX (t,n)) shows: *************************** 1. row *************************** id: 1 select_type: SIMPLE table: i1 type: range possible_keys: n,t key: t key_len: 28 ref: NULL rows: 70613 Extra: Using where; Using index 1 row in set (17.43 sec) SELECT works for ... +----------+ | count(*) | +----------+ | 379 | +----------+ 1 row in set (19.14 sec) And, with IGNORE INDEX (t,n): ... +----------+ | count(*) | +----------+ | 379 | +----------+ 1 row in set (0.32 sec) And the plan is: *************************** 1. row *************************** id: 1 select_type: SIMPLE table: i1 type: ALL possible_keys: NULL key: NULL key_len: NULL ref: NULL rows: 274737 Extra: Using where 1 row in set (0.00 sec) So, we do really have optimizer bug here.
[17 Aug 2007 18:43]
Igor Babaev
- This is not a bug: for some queries ANY DBMS can be forced to spend for the optimizer phase much more than for the execution phase. - There is no CSC bound to this case. - The problem existed always in all MySQL servers and was reported only in 2006. - Any query that requires long range optimization can be always rewritten to avoid this problem (e.g.: the predicate a IN <long list> can be replaced for a+0 IN <long list>. Range optimization is never performed for the last expression). - Currently we don't have a full and easy solution that would guarantee quite limited time for the range optimizer phase. By the above reasons I move the bug to 'To be fixed later' and mark it as a 'Feature request'. Product management will decide in what version this optimization appears.
[4 Nov 2008 18:56]
Eric DeCosta
One idea might be to have a parameter or option that would set a maximum time limit that the optimizer can spend evaluating a query.
[7 Jul 2010 10:51]
Michal Kovacik
Is there any chance that this will be fixed in future? We just upgrade mysql 4.0.x to 5.0.51 version so this type of queries became a problem. We have temporarily fixed this by appending +0 to column in one of IN conditions, but I believe, this is not supposed to be correct fix of the problem.
[8 Oct 2015 14:44]
Andrii Nikitin
Adding few more keywords about symptoms to improve search: Query is slow when IN() clause has many elements