Details
-
Task
-
Status: In Progress (View Workflow)
-
Major
-
Resolution: Unresolved
Description
Based on discussion with monty.
Motivation
There is some benchmarking effort where we suspect that records_in_range() calls make MariaDB slower than it could be.
The ranges being scanned are point lookups which have only a few records.
Note: there is another benchmark where I got a suspicion there might be a problem in records_in_range(), or recent changes to what InnoDB does in the function.
Solution
Skip records_in_range() when necessary.
Create a patch that adds an option to skip records_in_range() for equality intervals.
The record estimate can be taken from rec_per_key index statistics.
The decision whether to skip records_in_range() could be a configurable parameter: e.g. skip records_in_range() if the rec_per_key tells the range has at most N rows.
TODO: If the lookup value uses one keypart and have histogram on the column, would using n_distinct from the histogram give any advantage?
TODO: Or, we could examine the histogram to see if there are popular columns.
TODO: Or, we could just ask the histogram to estimate #rows for the key=const we have.
Add a counter.
Add a counter to count records_in_range( ) calls. Without it, it might be hard to check the above patches.