[MDEV-4145] Take into account the selectivity of single-table range predicates on non-indexed columns when searching for the best execution plan Created: 2012-08-14 Updated: 2013-10-29 Resolved: 2013-06-05 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major |
| Reporter: | Igor Babaev | Assignee: | Igor Babaev |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | mwl#253 | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
Description of the problem Currently the optimizer completely ignores any conditions on non-indexed columns when searching for the best execution plan. As a result in many cases it chooses a suboptimal plan. Let's consider the query: Under these conditions currently the optimizer will choose the plan that
This plan examines all rows of both tables and it performs 100 index look-ups. The alternative plan that:
The second plan is expected to be more efficient and it is so. The plan to resolve the problem 1. Build single-table range conditions over different columns of all tables of the join query. 2. Calculate the selectivity of each such condition using persistent statistics on table columns. 3. Take this statistics into account when calculated the cardinality of each partial join that are evaluated by the optimizer. |
| Comments |
| Comment by Igor Babaev [ 2013-06-05 ] |
|
The task was pushed into 10.0-base and appeared in 10.0.2 |
| Comment by roberto spadim [ 2013-06-10 ] |
|
please consider doing this: MDEV-4419 too, since ENUM() values is non-indexed but a very good information about values that should be in fields, example ENUM('a','b','c'), will never have a 'x' value, but can have a '' value or NULL value |