[MDEV-18378] Estimates for a non-merged join having implicit grouping is not showing 1 with optimizer_use_condition_selectivity >1 Created: 2019-01-25 Updated: 2023-04-27 |
|
| Status: | Stalled |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.0, 10.1, 10.2, 10.3, 10.4 |
| Fix Version/s: | 10.4 |
| Type: | Bug | Priority: | Major |
| Reporter: | Varun Gupta (Inactive) | Assignee: | Sergei Petrunia |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
MariaDB [test]> set optimizer_use_condition_selectivity=4;
The <subquery3> is materialised and has implicit grouping, so we are sure that it would have 1 record, but in the second case the estimate is 2. |
| Comments |
| Comment by Varun Gupta (Inactive) [ 2019-01-25 ] | |||||||||||||||||
|
Debugging for the case with optimizer_use_condition_selectivity=4
So here we see that <subquery3> has records 2 and selectivity=1 so we return 2 rows from here. | |||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2019-01-25 ] | |||||||||||||||||
|
Now for optimizer_use_condition_selectivity=1
So here we see that the <subquery3> has an estimate of 1 record. | |||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2019-01-25 ] | |||||||||||||||||
|
Patch | |||||||||||||||||
| Comment by Igor Babaev [ 2019-05-01 ] | |||||||||||||||||
|
Varun, | |||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2019-05-13 ] | |||||||||||||||||
|
For the query I switch off materialization, to cover the case when the subquery with implicit grouping is not filled at execution. So we use the IN -> EXISTS transformation here and the IN subquery is converted to EXISTS SELECT * FROM t1 So for <subquery3> we still would need to estimate all the rows for table t3 | |||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2019-05-13 ] | |||||||||||||||||
|
Ok after some investigations I see that for tables filled at execution we don't have any selectivities, we have a call to the function get_delayed_estimates(), which gives an estimate of the tables filled at execution. | |||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2019-05-14 ] | |||||||||||||||||
|
Patch |