Details
-
Task
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
None
-
None
Description
improve optimizer_use_condition_selectivity=5
- use it for more than LIKE
- basically, it could be used for any condition that is too complex to be estimated without sampling
- use random dives, not table scan
- get rid of optimizer_selectivity_sampling_limit
- either continue sampling until the result converges (using some hard-coded error marging and some safety check against sampling too much)
- or, ideally, sample as long as needed:
- sample a little bit, say, 10 rows. the selectivity will be within some range [sel min; sel max]
- this corresponds to two execution plans, Plan min with the cost Cost min and a Plan max with the cost Cost max
- we don't need more precise selectivity estimates as long as the best alternative plan is outside of [Cost min; Cost max]
- otherwise we have to sample just enough to narrow down the range until it no longer includes the best alternative plan (or until the range converges and stops shrinking)