[MDEV-7118] Anemometer stop working after upgrade to from 5.6 to 10.0 Created: 2014-11-14 Updated: 2014-11-19 Resolved: 2014-11-19 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.0.14 |
| Fix Version/s: | 10.0.15 |
| Type: | Bug | Priority: | Critical |
| Reporter: | VAROQUI Stephane | Assignee: | Sergei Petrunia |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
work around is :
was ok on MySQL 5.6 (without index hostname_max1)
Please backport |
| Comments |
| Comment by VAROQUI Stephane [ 2014-11-14 ] | ||||||||||||
|
| ||||||||||||
| Comment by Elena Stepanova [ 2014-11-14 ] | ||||||||||||
|
I suppose if psergey pushed the change for | ||||||||||||
| Comment by VAROQUI Stephane [ 2014-11-14 ] | ||||||||||||
|
After discussion on IRC with Sergei , it looks like it may be not related to 6657 but ignoring Using index for group-by on multi part keys , i sent sergei by email a dump to reproduce, do you need it for test case as well ? | ||||||||||||
| Comment by Elena Stepanova [ 2014-11-14 ] | ||||||||||||
|
It's enough if Sergei already has it, thanks. | ||||||||||||
| Comment by Sergei Petrunia [ 2014-11-15 ] | ||||||||||||
|
MariaDB 5.5.41:
| ||||||||||||
| Comment by Sergei Petrunia [ 2014-11-15 ] | ||||||||||||
|
MariaDB 10.0.15:
| ||||||||||||
| Comment by Sergei Petrunia [ 2014-11-15 ] | ||||||||||||
|
I'll need to investigate why 5.5 and 10.0 plans are different. | ||||||||||||
| Comment by Sergei Petrunia [ 2014-11-15 ] | ||||||||||||
|
The change is caused by: | ||||||||||||
| Comment by Sergei Petrunia [ 2014-11-15 ] | ||||||||||||
|
Looking at It is apparent that one shouldn't attempt to use Loose Index Scan over a full unique index. If index tuples are unique, jumping forward brings no benefits. However, prefix of unique index is not unique. It may have a very low cardinality, and it will make perfrect sense to use Loose Index Scan. | ||||||||||||
| Comment by Sergei Petrunia [ 2014-11-18 ] | ||||||||||||
|
.. on the other hand, if the index tuples are unique, why are we considering to use or not use loose index scan? We should be able to figure out that grouping is not needed at all. I mean, Loose Scan is applied in two cases: 1. DISTINCT which was converted into GROUP BY
2. GROUP BY with MIN/MAX
The testcase for
Here, one could argue that Loose Scan can still be a good strategy when (a1,a2,b) have low cardinality, while `c` has high cardinality. (we can't check whether the testcase for | ||||||||||||
| Comment by Sergei Petrunia [ 2014-11-18 ] | ||||||||||||
|
If I have a
and run a query:
I see that Loose Scan is considered, despite that the index is unique. The cost
If I adjust the cost numbers in so that loose index scan is chosen, it is used:
The same goes for "SELECT DISTINCT pk_part1, ... pk_partN". Perhaps, this is what | ||||||||||||
| Comment by VAROQUI Stephane [ 2014-11-18 ] | ||||||||||||
|
The cost of lose scan should be evaluated cost * (cardinality at the key_len /records) * cost_loose_scan_complexity /cost_index_scan_complexity | ||||||||||||
| Comment by Sergei Petrunia [ 2014-11-18 ] | ||||||||||||
|
[stephane], your formula is not clear.
Is this formula recursive? if not, what is cost_lose_scan_complexity and how is it different from cost of loose scan? | ||||||||||||
| Comment by Sergei Petrunia [ 2014-11-18 ] | ||||||||||||
|
Viable options so far
I am not sure if the second one is meaningful. I was not able to come up with a SELECT DISTINCT statement where cost of loose scan is smaller than the cost of index scan. Too bad we don't know the original testcase for | ||||||||||||
| Comment by Sergei Petrunia [ 2014-11-19 ] | ||||||||||||
|
Implemented the second option. Fix pushed into 10.0 tree. While debugging, also saw that Loose Index Scan cost formulas are poor - it can chose to use Loose Index Scan with group sizes as low as 4 rows, which seems to be wrong (at least, in some cases). |