[MDEV-27229] Estimation for filtered rows less precise with JSON histogram comparing to DOUBLE_PREC (#5) Created: 2021-12-11 Updated: 2022-01-25 Resolved: 2022-01-08 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | N/A |
| Fix Version/s: | 10.8.1 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Elena Stepanova | Assignee: | Sergei Petrunia |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
The condition filters a half of the rows (obviously). With JSON_HB the estimation is quite far off:
With DOUBLE_PREC the estimation is in this case precise:
|
| Comments |
| Comment by Elena Stepanova [ 2021-12-11 ] | ||||||||||||||||
|
Raised to critical on procedural reasons. | ||||||||||||||||
| Comment by Sergei Petrunia [ 2021-12-13 ] | ||||||||||||||||
|
Investigation:
We search for a > 'foo' 'foo' is between 'bar' and 'qux'. Histogram_json_hb::range_selectivity finds that 'foo' is after buckets[0].start_value and buckets[1].start_value. It assumes that buckets[0].size values are unformly distributed between buckets[0].start_value and buckets[1].start_value. It computes the position of 'foo' betwen 'bar' and 'qux', which is 0.26, and then returns the selectivity of 1 - (0.5 * 0.26)=0.86 |