[MDEV-19808] Add Optimizer Switch for Filesort with Small LIMIT Optimization Created: 2019-06-19 Updated: 2021-03-19 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major |
| Reporter: | Brad Jorgensen | Assignee: | Sergei Petrunia |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||
| Description |
|
In our environment we have several types of queries that use the filesort with small LIMIT optimization poorly. It causes some of our major queries to basically full scan the table instead of using a non-orderable index that is more effective. We were previously able to work around this by using "SET STATEMENT optimizer_switch='extended_keys=on FOR" but that has stopped working for us since upgrading from 10.1 to 10.2. I've tried using engine independent statistics, too but that didn't seem to help. We are currently using IGNORE INDEX in some cases but that is not ideal since the index we need to ignore is sometimes useful for filtering. Would it be possible to add an optimizer switch or some other config to control it? |
| Comments |
| Comment by Brad Jorgensen [ 2019-09-27 ] |
|
This may offer a temporary work around for people affected by this optimization choosing a bad plan. |
| Comment by Varun Gupta (Inactive) [ 2020-02-02 ] |
|
Could you share an example demonstrating the problem. Internally in the optimizer we try to use and index (non-ordered) when we have LIMIT clause as this would help us to filter rows (range scan is used in such cases). |