You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Range predicate estimate can be much lower than an equivalent point get estimate if the high/low range of a histogram covers a broader range of values. This is because range estimation uses an interpolation formula whereas point get estimates will default to 1/NDV. These should be relatively consistent.
Example below shows the same query written as between vs an IN predicate. The example used comes from mysql_test/t/select_all.test. And any predicate values can be used where the histograms show a large range.
tidb> explain select fld1 from t2 where fld1 between 228313 and 228314;
+------------------------+---------+-----------+----------------------------+-----------------------------------------+
| id | estRows | task | access object | operator info |
+------------------------+---------+-----------+----------------------------+-----------------------------------------+
| IndexReader_6 | 0.05 | root | | index:IndexRangeScan_5 |
| └─IndexRangeScan_5 | 0.05 | cop[tikv] | table:t2, index:fld1(fld1) | range:[228313,228314], keep order:false |
+------------------------+---------+-----------+----------------------------+-----------------------------------------+
tidb> explain select fld1 from t2 where fld1 in (228313, 228314);
+-------------------+---------+------+----------------------------+------------------------------+
| id | estRows | task | access object | operator info |
+-------------------+---------+------+----------------------------+------------------------------+
| Batch_Point_Get_1 | 2.00 | root | table:t2, index:fld1(fld1) | keep order:false, desc:false |
+-------------------+---------+------+----------------------------+------------------------------+
The text was updated successfully, but these errors were encountered:
Enhancement
Range predicate estimate can be much lower than an equivalent point get estimate if the high/low range of a histogram covers a broader range of values. This is because range estimation uses an interpolation formula whereas point get estimates will default to 1/NDV. These should be relatively consistent.
Example below shows the same query written as between vs an IN predicate. The example used comes from mysql_test/t/select_all.test. And any predicate values can be used where the histograms show a large range.
The text was updated successfully, but these errors were encountered: