Bug #43011 | inconsistent content for 'rows' column in EXPLAIN for index_merge | ||
---|---|---|---|
Submitted: | 19 Feb 2009 10:01 | Modified: | 15 Sep 2009 8:29 |
Reporter: | Andrii Nikitin | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S2 (Serious) |
Version: | 5.0.75, 5.0.*, 5.1.* | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[19 Feb 2009 10:01]
Andrii Nikitin
[19 Feb 2009 10:53]
Valeriy Kravchuk
Inconsistency is obvious: mysql> explain select count(*) from t where a=10\G *************************** 1. row *************************** id: 1 select_type: SIMPLE table: t type: ref possible_keys: ia key: ia key_len: 5 ref: const rows: 4919 Extra: Using where; Using index 1 row in set (0.00 sec) mysql> explain select count(*) from t where b=10\G *************************** 1. row *************************** id: 1 select_type: SIMPLE table: t type: ref possible_keys: ib key: ib key_len: 5 ref: const rows: 4758 Extra: Using where; Using index 1 row in set (0.00 sec) mysql> explain select count(*) from t where a=10 and b=10\G *************************** 1. row *************************** id: 1 select_type: SIMPLE table: t type: index_merge possible_keys: ia,ib key: ib,ia key_len: 5,5 ref: NULL rows: 234 Extra: Using intersect(ib,ia); Using where; Using index 1 row in set (0.02 sec) Index merge has to read rows from both indexes and merge them, so in "rows" we should not see, in any case, value smaller than estimation for each individual index. As other bugs referenced shows, this estimation is not only presented in EXPLAIN results, but is also used when comparing index merge with other possible access pathes.
[23 Feb 2009 16:21]
Sergey Petrunya
There is no way this could be related to BUG#41660. This bug is about execution and estimates, while that bug is about malloc discipline to be used at execution phase.
[23 Feb 2009 16:28]
Sergey Petrunya
I think the number show in EXPLAIN is correct. There is place for only one number there, and given the choice, we would put in "The number of records which will be produced by the used access method", or "The number of records that will remain after the records that were produced by the chosen access method were joined with the records of preceding tables". Putting the number of enumerated index tuples would be greatly misleading for all join cases.
[23 Feb 2009 16:29]
Sergey Petrunya
Here's a patch that introduces switches to disable index_merge or its individual strategies: http://lists.mysql.com/commits/67226 . It may be used as a makeshift measure before we fix cost model.
[10 Sep 2009 16:37]
MySQL Verification Team
Valeriy, I do not think that this is a bug. Our optimizer calculates the approximate number of rows that will be contained in the intersect. That is very nice, and hence 'rows' column is correct. You can have two indices , each having one million rows, but which intersect in one row only.