diff --git a/pkg/planner/cardinality/BUILD.bazel b/pkg/planner/cardinality/BUILD.bazel index 51b059bfec680..4446861b0e7a9 100644 --- a/pkg/planner/cardinality/BUILD.bazel +++ b/pkg/planner/cardinality/BUILD.bazel @@ -26,6 +26,7 @@ go_library( "//pkg/planner/property", "//pkg/planner/util", "//pkg/planner/util/debugtrace", + "//pkg/planner/util/fixcontrol", "//pkg/sessionctx/stmtctx", "//pkg/statistics", "//pkg/tablecodec", diff --git a/pkg/planner/cardinality/row_count_column.go b/pkg/planner/cardinality/row_count_column.go index c0f19fa0d8acc..1f077e513cc54 100644 --- a/pkg/planner/cardinality/row_count_column.go +++ b/pkg/planner/cardinality/row_count_column.go @@ -18,6 +18,7 @@ import ( "github.com/pingcap/errors" "github.com/pingcap/tidb/pkg/planner/context" "github.com/pingcap/tidb/pkg/planner/util/debugtrace" + "github.com/pingcap/tidb/pkg/planner/util/fixcontrol" "github.com/pingcap/tidb/pkg/statistics" "github.com/pingcap/tidb/pkg/types" "github.com/pingcap/tidb/pkg/util/codec" @@ -312,7 +313,17 @@ func GetColumnRowCount(sctx context.PlanContext, c *statistics.Column, ranges [] } rowCount += cnt } - rowCount = mathutil.Clamp(rowCount, 0, float64(realtimeRowCount)) + allowZeroEst := fixcontrol.GetBoolWithDefault( + sctx.GetSessionVars().GetOptimizerFixControlMap(), + fixcontrol.Fix47400, + false, + ) + if allowZeroEst { + rowCount = mathutil.Clamp(rowCount, 0, float64(realtimeRowCount)) + } else { + // Don't allow the final result to go below 1 row + rowCount = mathutil.Clamp(rowCount, 1, float64(realtimeRowCount)) + } return rowCount, nil } diff --git a/pkg/planner/cardinality/row_count_index.go b/pkg/planner/cardinality/row_count_index.go index 8d42904d4796f..1b7065662d047 100644 --- a/pkg/planner/cardinality/row_count_index.go +++ b/pkg/planner/cardinality/row_count_index.go @@ -26,6 +26,7 @@ import ( "github.com/pingcap/tidb/pkg/kv" "github.com/pingcap/tidb/pkg/planner/context" "github.com/pingcap/tidb/pkg/planner/util/debugtrace" + "github.com/pingcap/tidb/pkg/planner/util/fixcontrol" "github.com/pingcap/tidb/pkg/sessionctx/stmtctx" "github.com/pingcap/tidb/pkg/statistics" "github.com/pingcap/tidb/pkg/types" @@ -350,7 +351,17 @@ func getIndexRowCountForStatsV2(sctx context.PlanContext, idx *statistics.Index, } totalCount += count } - totalCount = mathutil.Clamp(totalCount, 0, float64(realtimeRowCount)) + allowZeroEst := fixcontrol.GetBoolWithDefault( + sctx.GetSessionVars().GetOptimizerFixControlMap(), + fixcontrol.Fix47400, + false, + ) + if allowZeroEst { + totalCount = mathutil.Clamp(totalCount, 0, float64(realtimeRowCount)) + } else { + // Don't allow the final result to go below 1 row + totalCount = mathutil.Clamp(totalCount, 1, float64(realtimeRowCount)) + } return totalCount, nil } diff --git a/pkg/planner/cardinality/selectivity_test.go b/pkg/planner/cardinality/selectivity_test.go index af92484ba2bd1..459cfd8cd7f7b 100644 --- a/pkg/planner/cardinality/selectivity_test.go +++ b/pkg/planner/cardinality/selectivity_test.go @@ -236,7 +236,7 @@ func TestEstimationForUnknownValues(t *testing.T) { colID := table.Meta().Columns[0].ID count, err := cardinality.GetRowCountByColumnRanges(sctx, &statsTbl.HistColl, colID, getRange(30, 30)) require.NoError(t, err) - require.Equal(t, 0.2, count) + require.Equal(t, 1.0, count) count, err = cardinality.GetRowCountByColumnRanges(sctx, &statsTbl.HistColl, colID, getRange(9, 30)) require.NoError(t, err) @@ -265,7 +265,7 @@ func TestEstimationForUnknownValues(t *testing.T) { colID = table.Meta().Columns[0].ID count, err = cardinality.GetRowCountByColumnRanges(sctx, &statsTbl.HistColl, colID, getRange(1, 30)) require.NoError(t, err) - require.Equal(t, 0.0, count) + require.Equal(t, 1.0, count) testKit.MustExec("drop table t") testKit.MustExec("create table t(a int, b int, index idx(b))") @@ -278,7 +278,7 @@ func TestEstimationForUnknownValues(t *testing.T) { colID = table.Meta().Columns[0].ID count, err = cardinality.GetRowCountByColumnRanges(sctx, &statsTbl.HistColl, colID, getRange(2, 2)) require.NoError(t, err) - require.Equal(t, 0.0, count) + require.Equal(t, 1.0, count) idxID = table.Meta().Indices[0].ID count, err = cardinality.GetRowCountByIndexRanges(sctx, &statsTbl.HistColl, idxID, getRange(2, 2)) @@ -402,8 +402,8 @@ func TestSelectivity(t *testing.T) { }, { exprs: "a >= 1 and b > 1 and a < 2", - selectivity: 0.01783264746, - selectivityAfterIncrease: 0.01851851852, + selectivity: 0.017832647462277088, + selectivityAfterIncrease: 0.018518518518518517, }, { exprs: "a >= 1 and c > 1 and a < 2", @@ -422,13 +422,13 @@ func TestSelectivity(t *testing.T) { }, { exprs: "b > 1", - selectivity: 0.96296296296, + selectivity: 0.9629629629629629, selectivityAfterIncrease: 1, }, { exprs: "a > 1 and b < 2 and c > 3 and d < 4 and e > 5", - selectivity: 0, - selectivityAfterIncrease: 0, + selectivity: 5.870830440255832e-05, + selectivityAfterIncrease: 1.51329827770157e-05, }, { exprs: longExpr, @@ -1190,8 +1190,8 @@ func TestCrossValidationSelectivity(t *testing.T) { require.NoError(t, h.DumpStatsDeltaToKV(true)) tk.MustExec("analyze table t") tk.MustQuery("explain format = 'brief' select * from t where a = 1 and b > 0 and b < 1000 and c > 1000").Check(testkit.Rows( - "TableReader 0.00 root data:Selection", - "└─Selection 0.00 cop[tikv] gt(test.t.c, 1000)", + "TableReader 1.00 root data:Selection", + "└─Selection 1.00 cop[tikv] gt(test.t.c, 1000)", " └─TableRangeScan 2.00 cop[tikv] table:t range:(1 0,1 1000), keep order:false")) } diff --git a/pkg/planner/cardinality/testdata/cardinality_suite_out.json b/pkg/planner/cardinality/testdata/cardinality_suite_out.json index 4ea3d621a19e2..cfae3231c3f52 100644 --- a/pkg/planner/cardinality/testdata/cardinality_suite_out.json +++ b/pkg/planner/cardinality/testdata/cardinality_suite_out.json @@ -24,7 +24,7 @@ { "Start": 800, "End": 900, - "Count": 755.754166655054 + "Count": 791.004166655054 }, { "Start": 900, @@ -79,7 +79,7 @@ { "Start": 800, "End": 1000, - "Count": 1213.946869573942 + "Count": 1249.196869573942 }, { "Start": 900, @@ -104,7 +104,7 @@ { "Start": 200, "End": 400, - "Count": 1215.0288209899081 + "Count": 1188.7788209899081 }, { "Start": 200, @@ -2589,7 +2589,7 @@ }, { "Name": "a", - "Result": 0 + "Result": 1 } ] }, @@ -2887,7 +2887,7 @@ }, { "End estimate range": { - "RowCount": 0, + "RowCount": 1, "Type": "Range" } } @@ -2895,7 +2895,7 @@ }, { "Name": "iab", - "Result": 0 + "Result": 1 } ] }, @@ -3447,11 +3447,11 @@ "Expressions": [ "lt(test.t.a, -1500)" ], - "Selectivity": 0, + "Selectivity": 0.0003246753246753247, "partial cover": false }, { - "Result": 0 + "Result": 2.1082813290605499e-7 } ] } @@ -3940,7 +3940,7 @@ }, { "Name": "iab", - "Result": 0 + "Result": 1 } ] }, @@ -4093,11 +4093,11 @@ "Expressions": [ "lt(test.t.a, -1500)" ], - "Selectivity": 0, + "Selectivity": 0.0003246753246753247, "partial cover": false }, { - "Result": 0 + "Result": 1.9066503965832828e-7 } ] } diff --git a/pkg/planner/core/casetest/cbotest/testdata/analyze_suite_out.json b/pkg/planner/core/casetest/cbotest/testdata/analyze_suite_out.json index 1700e53db17fc..41838a6310fd7 100644 --- a/pkg/planner/core/casetest/cbotest/testdata/analyze_suite_out.json +++ b/pkg/planner/core/casetest/cbotest/testdata/analyze_suite_out.json @@ -364,13 +364,13 @@ "└─TableRowIDScan(Probe) 2.00 cop[tikv] table:t keep order:false" ], [ - "TableReader 0.00 root data:Selection", - "└─Selection 0.00 cop[tikv] eq(test.t.b, 1)", + "TableReader 1.00 root data:Selection", + "└─Selection 1.00 cop[tikv] eq(test.t.b, 1)", " └─TableFullScan 2.00 cop[tikv] table:t keep order:false" ], [ - "TableReader 0.00 root data:Selection", - "└─Selection 0.00 cop[tikv] lt(test.t.b, 1)", + "TableReader 1.00 root data:Selection", + "└─Selection 1.00 cop[tikv] lt(test.t.b, 1)", " └─TableFullScan 2.00 cop[tikv] table:t keep order:false" ] ] diff --git a/pkg/planner/core/casetest/partition/testdata/integration_partition_suite_out.json b/pkg/planner/core/casetest/partition/testdata/integration_partition_suite_out.json index 71456e2d40833..e70e65ab26ccd 100644 --- a/pkg/planner/core/casetest/partition/testdata/integration_partition_suite_out.json +++ b/pkg/planner/core/casetest/partition/testdata/integration_partition_suite_out.json @@ -709,7 +709,7 @@ "└─IndexRangeScan 1.00 cop[tikv] table:t, index:b(b) range:[1,1], keep order:false" ], "StaticPlan": [ - "PartitionUnion 1.00 root ", + "PartitionUnion 3.00 root ", "├─IndexReader 1.00 root index:IndexRangeScan", "│ └─IndexRangeScan 1.00 cop[tikv] table:t, partition:P0, index:b(b) range:[1,1], keep order:false", "├─IndexReader 1.00 root index:IndexRangeScan", @@ -725,7 +725,7 @@ "└─IndexRangeScan 1.00 cop[tikv] table:t, index:b(b) range:[2,2], keep order:false" ], "StaticPlan": [ - "PartitionUnion 1.00 root ", + "PartitionUnion 3.00 root ", "├─IndexReader 1.00 root index:IndexRangeScan", "│ └─IndexRangeScan 1.00 cop[tikv] table:t, partition:P0, index:b(b) range:[2,2], keep order:false", "├─IndexReader 1.00 root index:IndexRangeScan", @@ -741,7 +741,7 @@ "└─IndexRangeScan 2.00 cop[tikv] table:t, index:b(b) range:[1,2], keep order:false" ], "StaticPlan": [ - "PartitionUnion 2.00 root ", + "PartitionUnion 3.00 root ", "├─IndexReader 1.00 root index:IndexRangeScan", "│ └─IndexRangeScan 1.00 cop[tikv] table:t, partition:P0, index:b(b) range:[1,2], keep order:false", "├─IndexReader 1.00 root index:IndexRangeScan", @@ -757,7 +757,7 @@ "└─IndexRangeScan 2.00 cop[tikv] table:t, index:b(b) range:[2,2], [3,3], [4,4], keep order:false" ], "StaticPlan": [ - "PartitionUnion 2.00 root ", + "PartitionUnion 3.00 root ", "├─IndexReader 1.00 root index:IndexRangeScan", "│ └─IndexRangeScan 1.00 cop[tikv] table:t, partition:P0, index:b(b) range:[2,2], [3,3], [4,4], keep order:false", "├─IndexReader 1.00 root index:IndexRangeScan", @@ -773,7 +773,7 @@ "└─IndexRangeScan 2.00 cop[tikv] table:t, index:b(b) range:[2,2], [3,3], keep order:false" ], "StaticPlan": [ - "PartitionUnion 2.00 root ", + "PartitionUnion 3.00 root ", "├─IndexReader 1.00 root index:IndexRangeScan", "│ └─IndexRangeScan 1.00 cop[tikv] table:t, partition:P0, index:b(b) range:[2,2], [3,3], keep order:false", "├─IndexReader 1.00 root index:IndexRangeScan", @@ -854,7 +854,7 @@ "└─IndexRangeScan 1.00 cop[tikv] table:t, index:b(b) range:[1,1], keep order:false" ], "StaticPlan": [ - "PartitionUnion 1.00 root ", + "PartitionUnion 2.00 root ", "├─IndexReader 1.00 root index:IndexRangeScan", "│ └─IndexRangeScan 1.00 cop[tikv] table:t, partition:P0, index:b(b) range:[1,1], keep order:false", "└─IndexReader 1.00 root index:IndexRangeScan", diff --git a/pkg/planner/core/casetest/planstats/testdata/plan_stats_suite_out.json b/pkg/planner/core/casetest/planstats/testdata/plan_stats_suite_out.json index 92f1647bb88d7..e61f53ded7ca2 100644 --- a/pkg/planner/core/casetest/planstats/testdata/plan_stats_suite_out.json +++ b/pkg/planner/core/casetest/planstats/testdata/plan_stats_suite_out.json @@ -116,10 +116,10 @@ { "Query": "explain format = brief select * from t join tp where tp.a = 10 and t.b = tp.c", "Result": [ - "Projection 0.00 root test.t.a, test.t.b, test.t.c, test.tp.a, test.tp.b, test.tp.c", - "└─HashJoin 0.00 root inner join, equal:[eq(test.tp.c, test.t.b)]", - " ├─TableReader(Build) 0.00 root partition:p1 data:Selection", - " │ └─Selection 0.00 cop[tikv] eq(test.tp.a, 10), not(isnull(test.tp.c))", + "Projection 1.00 root test.t.a, test.t.b, test.t.c, test.tp.a, test.tp.b, test.tp.c", + "└─HashJoin 1.00 root inner join, equal:[eq(test.tp.c, test.t.b)]", + " ├─TableReader(Build) 1.00 root partition:p1 data:Selection", + " │ └─Selection 1.00 cop[tikv] eq(test.tp.a, 10), not(isnull(test.tp.c))", " │ └─TableFullScan 6.00 cop[tikv] table:tp keep order:false, stats:partial[c:allEvicted]", " └─TableReader(Probe) 3.00 root data:Selection", " └─Selection 3.00 cop[tikv] not(isnull(test.t.b))", diff --git a/pkg/planner/core/casetest/testdata/integration_suite_out.json b/pkg/planner/core/casetest/testdata/integration_suite_out.json index 56e395c23816e..ffe733cb7fec8 100644 --- a/pkg/planner/core/casetest/testdata/integration_suite_out.json +++ b/pkg/planner/core/casetest/testdata/integration_suite_out.json @@ -93,25 +93,25 @@ "SQL": "explain format = 'verbose' select count(*) from t3 where b = 0", "Plan": [ "StreamAgg_10 1.00 64.98 root funcs:count(1)->Column#4", - "└─IndexReader_15 0.00 15.08 root index:IndexRangeScan_14", - " └─IndexRangeScan_14 0.00 162.80 cop[tikv] table:t3, index:c(b) range:[0,0], keep order:false" + "└─IndexReader_15 1.00 15.08 root index:IndexRangeScan_14", + " └─IndexRangeScan_14 1.00 162.80 cop[tikv] table:t3, index:c(b) range:[0,0], keep order:false" ] }, { "SQL": "explain format = 'verbose' select /*+ use_index(t3, c) */ count(a) from t3 where b = 0", "Plan": [ "StreamAgg_10 1.00 2001.63 root funcs:count(test.t3.a)->Column#4", - "└─IndexLookUp_17 0.00 1951.73 root ", - " ├─IndexRangeScan_15(Build) 0.00 203.50 cop[tikv] table:t3, index:c(b) range:[0,0], keep order:false", - " └─TableRowIDScan_16(Probe) 0.00 227.31 cop[tikv] table:t3 keep order:false" + "└─IndexLookUp_17 1.00 1951.73 root ", + " ├─IndexRangeScan_15(Build) 1.00 203.50 cop[tikv] table:t3, index:c(b) range:[0,0], keep order:false", + " └─TableRowIDScan_16(Probe) 1.00 227.31 cop[tikv] table:t3 keep order:false" ] }, { "SQL": "explain format = 'verbose' select count(*) from t2 where a = 0", "Plan": [ "StreamAgg_12 1.00 109.57 root funcs:count(1)->Column#4", - "└─TableReader_20 0.00 59.67 root data:Selection_19", - " └─Selection_19 0.00 831.62 cop[tikv] eq(test.t2.a, 0)", + "└─TableReader_20 1.00 59.67 root data:Selection_19", + " └─Selection_19 1.00 831.62 cop[tikv] eq(test.t2.a, 0)", " └─TableFullScan_18 3.00 681.92 cop[tikv] table:t2 keep order:false" ] }, diff --git a/pkg/planner/core/casetest/testdata/plan_normalized_suite_out.json b/pkg/planner/core/casetest/testdata/plan_normalized_suite_out.json index bc910fa299f9e..d9ad1168af8c3 100644 --- a/pkg/planner/core/casetest/testdata/plan_normalized_suite_out.json +++ b/pkg/planner/core/casetest/testdata/plan_normalized_suite_out.json @@ -461,8 +461,8 @@ "Plan": [ " TableReader root ", " └─ExchangeSender cop[tiflash] ", - " └─Selection cop[tiflash] gt(test.t1.b, ?), gt(test.t1.c, ?), or(gt(test.t1.a, ?), lt(test.t1.b, ?))", - " └─TableFullScan cop[tiflash] table:t1, range:[?,?], pushed down filter:gt(test.t1.a, ?), keep order:false" + " └─Selection cop[tiflash] gt(test.t1.a, ?), gt(test.t1.c, ?), or(gt(test.t1.a, ?), lt(test.t1.b, ?))", + " └─TableFullScan cop[tiflash] table:t1, range:[?,?], pushed down filter:gt(test.t1.b, ?), keep order:false" ] }, { diff --git a/pkg/planner/core/testdata/index_merge_suite_out.json b/pkg/planner/core/testdata/index_merge_suite_out.json index 0d98061beedd1..66cc33e82a435 100644 --- a/pkg/planner/core/testdata/index_merge_suite_out.json +++ b/pkg/planner/core/testdata/index_merge_suite_out.json @@ -252,7 +252,7 @@ { "SQL": "select * from vh", "Plan": [ - "PartitionUnion 0.50 root ", + "PartitionUnion 1.50 root ", "├─IndexMerge 0.50 root type: intersection", "│ ├─IndexRangeScan(Build) 2.00 cop[tikv] table:t1, partition:p0, index:ia(a) range:[10,10], keep order:false", "│ ├─IndexRangeScan(Build) 1.00 cop[tikv] table:t1, partition:p0, index:ibc(b, c) range:[20 -inf,20 30), keep order:false", @@ -276,7 +276,7 @@ { "SQL": "select /*+ qb_name(v, v), use_index_merge(@v t1, ia, ibc, id) */ * from v", "Plan": [ - "PartitionUnion 0.50 root ", + "PartitionUnion 1.50 root ", "├─IndexMerge 0.50 root type: intersection", "│ ├─IndexRangeScan(Build) 2.00 cop[tikv] table:t1, partition:p0, index:ia(a) range:[10,10], keep order:false", "│ ├─IndexRangeScan(Build) 1.00 cop[tikv] table:t1, partition:p0, index:ibc(b, c) range:[20 -inf,20 30), keep order:false", @@ -300,7 +300,7 @@ { "SQL": "select /*+ qb_name(v, v@sel_1), use_index_merge(@v t1, ia, ibc, id) */ * from v", "Plan": [ - "PartitionUnion 0.50 root ", + "PartitionUnion 1.50 root ", "├─IndexMerge 0.50 root type: intersection", "│ ├─IndexRangeScan(Build) 2.00 cop[tikv] table:t1, partition:p0, index:ia(a) range:[10,10], keep order:false", "│ ├─IndexRangeScan(Build) 1.00 cop[tikv] table:t1, partition:p0, index:ibc(b, c) range:[20 -inf,20 30), keep order:false", @@ -324,7 +324,7 @@ { "SQL": "select /*+ qb_name(v, v@sel_1 .@sel_1), use_index_merge(@v t1, ia, ibc, id) */ * from v", "Plan": [ - "PartitionUnion 0.50 root ", + "PartitionUnion 1.50 root ", "├─IndexMerge 0.50 root type: intersection", "│ ├─IndexRangeScan(Build) 2.00 cop[tikv] table:t1, partition:p0, index:ia(a) range:[10,10], keep order:false", "│ ├─IndexRangeScan(Build) 1.00 cop[tikv] table:t1, partition:p0, index:ibc(b, c) range:[20 -inf,20 30), keep order:false", @@ -348,7 +348,7 @@ { "SQL": "select /*+ qb_name(v, v@sel_1 .@sel_1), use_index_merge(@v t1, ia, ibc, id) */ * from v", "Plan": [ - "PartitionUnion 0.50 root ", + "PartitionUnion 1.50 root ", "├─IndexMerge 0.50 root type: intersection", "│ ├─IndexRangeScan(Build) 2.00 cop[tikv] table:t1, partition:p0, index:ia(a) range:[10,10], keep order:false", "│ ├─IndexRangeScan(Build) 1.00 cop[tikv] table:t1, partition:p0, index:ibc(b, c) range:[20 -inf,20 30), keep order:false", diff --git a/pkg/planner/core/testdata/runtime_filter_generator_suite_out.json b/pkg/planner/core/testdata/runtime_filter_generator_suite_out.json index 131c9e9c6c219..158cfc64b6e4b 100644 --- a/pkg/planner/core/testdata/runtime_filter_generator_suite_out.json +++ b/pkg/planner/core/testdata/runtime_filter_generator_suite_out.json @@ -5,14 +5,14 @@ { "SQL": "select /*+ hash_join_build(t1) */ * from t1, t2 where t1.k1=t2.k1 and t2.k2 = 1", "Plan": [ - "TableReader_32 0.00 root MppVersion: 2, data:ExchangeSender_31", - "└─ExchangeSender_31 0.00 mpp[tiflash] ExchangeType: PassThrough", - " └─HashJoin_24 0.00 mpp[tiflash] inner join, equal:[eq(test.t1.k1, test.t2.k1)], runtime filter:0[IN] <- test.t1.k1", + "TableReader_32 1.00 root MppVersion: 2, data:ExchangeSender_31", + "└─ExchangeSender_31 1.00 mpp[tiflash] ExchangeType: PassThrough", + " └─HashJoin_24 1.00 mpp[tiflash] inner join, equal:[eq(test.t1.k1, test.t2.k1)], runtime filter:0[IN] <- test.t1.k1", " ├─ExchangeReceiver_28(Build) 1.00 mpp[tiflash] ", " │ └─ExchangeSender_27 1.00 mpp[tiflash] ExchangeType: Broadcast, Compression: FAST", " │ └─Selection_26 1.00 mpp[tiflash] not(isnull(test.t1.k1))", " │ └─TableFullScan_25 1.00 mpp[tiflash] table:t1 pushed down filter:empty, keep order:false", - " └─Selection_30(Probe) 0.00 mpp[tiflash] eq(test.t2.k2, 1), not(isnull(test.t2.k1))", + " └─Selection_30(Probe) 1.00 mpp[tiflash] eq(test.t2.k2, 1), not(isnull(test.t2.k1))", " └─TableFullScan_29 1.00 mpp[tiflash] table:t2 pushed down filter:empty, keep order:false, runtime filter:0[IN] -> test.t2.k1" ] }, diff --git a/pkg/planner/util/fixcontrol/get.go b/pkg/planner/util/fixcontrol/get.go index c2bed71c7b47f..33d1d083ec37b 100644 --- a/pkg/planner/util/fixcontrol/get.go +++ b/pkg/planner/util/fixcontrol/get.go @@ -11,6 +11,9 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// +// NOTE: For assigning new fix control numbers - use the issue number associated with the fix. +// package fixcontrol @@ -48,6 +51,8 @@ const ( Fix45798 uint64 = 45798 // Fix46177 controls whether to explore enforced plans for DataSource if it has already found an unenforced plan. Fix46177 uint64 = 46177 + // Fix47400 controls whether to allow a rowEst below 1 + Fix47400 uint64 = 47400 // Fix49736 controls whether to force the optimizer to use plan cache even if there is risky optimization. // This fix-control is test-only. Fix49736 uint64 = 49736 diff --git a/pkg/statistics/handle/globalstats/global_stats_test.go b/pkg/statistics/handle/globalstats/global_stats_test.go index 8a424aa483f15..828ff6e35b8d3 100644 --- a/pkg/statistics/handle/globalstats/global_stats_test.go +++ b/pkg/statistics/handle/globalstats/global_stats_test.go @@ -783,9 +783,9 @@ func TestGlobalStats(t *testing.T) { // Even if we have global-stats, we will not use it when the switch is set to `static`. tk.MustExec("set @@tidb_partition_prune_mode = 'static';") tk.MustQuery("explain format = 'brief' select a from t where a > 5").Check(testkit.Rows( - "PartitionUnion 4.00 root ", - "├─IndexReader 0.00 root index:IndexRangeScan", - "│ └─IndexRangeScan 0.00 cop[tikv] table:t, partition:p0, index:a(a) range:(5,+inf], keep order:false", + "PartitionUnion 5.00 root ", + "├─IndexReader 1.00 root index:IndexRangeScan", + "│ └─IndexRangeScan 1.00 cop[tikv] table:t, partition:p0, index:a(a) range:(5,+inf], keep order:false", "├─IndexReader 2.00 root index:IndexRangeScan", "│ └─IndexRangeScan 2.00 cop[tikv] table:t, partition:p1, index:a(a) range:(5,+inf], keep order:false", "└─IndexReader 2.00 root index:IndexRangeScan", diff --git a/pkg/statistics/handle/handletest/handle_test.go b/pkg/statistics/handle/handletest/handle_test.go index 51cb295f3adc9..5c83c9e23a8c5 100644 --- a/pkg/statistics/handle/handletest/handle_test.go +++ b/pkg/statistics/handle/handletest/handle_test.go @@ -95,7 +95,7 @@ func TestColumnIDs(t *testing.T) { // At that time, we should get c2's stats instead of c1's. count, err = cardinality.GetRowCountByColumnRanges(sctx, &statsTbl.HistColl, tableInfo.Columns[0].ID, []*ranger.Range{ran}) require.NoError(t, err) - require.Equal(t, 0.0, count) + require.Equal(t, 1.0, count) } func TestDurationToTS(t *testing.T) { diff --git a/pkg/statistics/statistics_test.go b/pkg/statistics/statistics_test.go index fe18ee80b0ee3..ca192db2f0d24 100644 --- a/pkg/statistics/statistics_test.go +++ b/pkg/statistics/statistics_test.go @@ -441,7 +441,7 @@ func SubTestIndexRanges() func(*testing.T) { ran[0].HighVal[0] = types.NewIntDatum(1000) count, err = GetRowCountByIndexRanges(ctx, &tbl.HistColl, 0, ran) require.NoError(t, err) - require.Equal(t, 0, int(count)) + require.Equal(t, 1, int(count)) } } diff --git a/pkg/statistics/testdata/integration_suite_out.json b/pkg/statistics/testdata/integration_suite_out.json index e2706b96dd588..14cdc66e90ce0 100644 --- a/pkg/statistics/testdata/integration_suite_out.json +++ b/pkg/statistics/testdata/integration_suite_out.json @@ -26,8 +26,8 @@ "└─IndexRangeScan_5 1.36 cop[tikv] table:exp_backoff, index:idx(a, b, c, d) range:[1 1 1 3,1 1 1 5], keep order:false" ], [ - "IndexReader_6 0.00 root index:IndexRangeScan_5", - "└─IndexRangeScan_5 0.00 cop[tikv] table:exp_backoff, index:idx(a, b, c, d) range:[1 1 1 3,1 1 1 5], keep order:false" + "IndexReader_6 1.00 root index:IndexRangeScan_5", + "└─IndexRangeScan_5 1.00 cop[tikv] table:exp_backoff, index:idx(a, b, c, d) range:[1 1 1 3,1 1 1 5], keep order:false" ] ] }, diff --git a/pkg/table/tables/test/partition/partition_test.go b/pkg/table/tables/test/partition/partition_test.go index 418ac3a0acf8f..c252d44f05b5d 100644 --- a/pkg/table/tables/test/partition/partition_test.go +++ b/pkg/table/tables/test/partition/partition_test.go @@ -3246,8 +3246,8 @@ func TestPartitionCoverage(t *testing.T) { " └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo")) tk.MustExec(`analyze table t all columns`) tk.MustQuery(`explain format='brief' select * from t where a = 10`).Check(testkit.Rows(""+ - `TableReader 0.00 root partition:dual data:Selection`, - `└─Selection 0.00 cop[tikv] eq(test.t.a, 10)`, + `TableReader 1.00 root partition:dual data:Selection`, + `└─Selection 1.00 cop[tikv] eq(test.t.a, 10)`, ` └─TableFullScan 1.00 cop[tikv] table:t keep order:false`)) tk.MustQuery(`select * from t where a = 10`).Check(testkit.Rows()) diff --git a/tests/integrationtest/r/executor/partition/partition_boundaries.result b/tests/integrationtest/r/executor/partition/partition_boundaries.result index fbb2627e500ea..5148ee5e34696 100644 --- a/tests/integrationtest/r/executor/partition/partition_boundaries.result +++ b/tests/integrationtest/r/executor/partition/partition_boundaries.result @@ -125,29 +125,29 @@ a b 1000002 1000002 Filler ... explain format='brief' SELECT * FROM t WHERE a = 3000000; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] eq(executor__partition__partition_boundaries.t.a, 3000000) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] eq(executor__partition__partition_boundaries.t.a, 3000000) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a = 3000000; a b explain format='brief' SELECT * FROM t WHERE a IN (3000000); id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] eq(executor__partition__partition_boundaries.t.a, 3000000) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] eq(executor__partition__partition_boundaries.t.a, 3000000) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a IN (3000000); a b explain format='brief' SELECT * FROM t WHERE a = 3000001; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] eq(executor__partition__partition_boundaries.t.a, 3000001) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] eq(executor__partition__partition_boundaries.t.a, 3000001) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a = 3000001; a b explain format='brief' SELECT * FROM t WHERE a IN (3000001); id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] eq(executor__partition__partition_boundaries.t.a, 3000001) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] eq(executor__partition__partition_boundaries.t.a, 3000001) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a IN (3000001); a b @@ -161,8 +161,8 @@ a b -2147483648 MIN_INT filler... explain format='brief' SELECT * FROM t WHERE a IN (-2147483647, -2147483646); id estRows task access object operator info -TableReader 0.00 root partition:p0 data:Selection -└─Selection 0.00 cop[tikv] in(executor__partition__partition_boundaries.t.a, -2147483647, -2147483646) +TableReader 1.00 root partition:p0 data:Selection +└─Selection 1.00 cop[tikv] in(executor__partition__partition_boundaries.t.a, -2147483647, -2147483646) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a IN (-2147483647, -2147483646); a b @@ -272,8 +272,8 @@ a b 2999999 2999999 Filler ... explain format='brief' SELECT * FROM t WHERE a IN (3000000, 3000001, 3000002); id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] in(executor__partition__partition_boundaries.t.a, 3000000, 3000001, 3000002) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] in(executor__partition__partition_boundaries.t.a, 3000000, 3000001, 3000002) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a IN (3000000, 3000001, 3000002); a b @@ -342,8 +342,8 @@ a b 6 6 Filler... explain format='brief' SELECT * FROM t WHERE 1 = 0 OR a = -1; id estRows task access object operator info -TableReader 0.00 root partition:p0 data:Selection -└─Selection 0.00 cop[tikv] or(0, eq(executor__partition__partition_boundaries.t.a, -1)) +TableReader 1.00 root partition:p0 data:Selection +└─Selection 1.00 cop[tikv] or(0, eq(executor__partition__partition_boundaries.t.a, -1)) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE 1 = 0 OR a = -1; a b @@ -629,15 +629,15 @@ a b 5 5 Filler... explain format='brief' SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1 AND a != 2 AND a != 3 AND a != 4 AND a != 5 AND a != 6; id estRows task access object operator info -TableReader 0.00 root partition:all data:Selection -└─Selection 0.00 cop[tikv] ne(executor__partition__partition_boundaries.t.a, -1), ne(executor__partition__partition_boundaries.t.a, 0), ne(executor__partition__partition_boundaries.t.a, 1), ne(executor__partition__partition_boundaries.t.a, 2), ne(executor__partition__partition_boundaries.t.a, 3), ne(executor__partition__partition_boundaries.t.a, 4), ne(executor__partition__partition_boundaries.t.a, 5), ne(executor__partition__partition_boundaries.t.a, 6) +TableReader 1.00 root partition:all data:Selection +└─Selection 1.00 cop[tikv] ne(executor__partition__partition_boundaries.t.a, -1), ne(executor__partition__partition_boundaries.t.a, 0), ne(executor__partition__partition_boundaries.t.a, 1), ne(executor__partition__partition_boundaries.t.a, 2), ne(executor__partition__partition_boundaries.t.a, 3), ne(executor__partition__partition_boundaries.t.a, 4), ne(executor__partition__partition_boundaries.t.a, 5), ne(executor__partition__partition_boundaries.t.a, 6) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1 AND a != 2 AND a != 3 AND a != 4 AND a != 5 AND a != 6; a b explain format='brief' SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1, 2, 3, 4, 5, 6); id estRows task access object operator info -TableReader 0.00 root partition:all data:Selection -└─Selection 0.00 cop[tikv] not(in(executor__partition__partition_boundaries.t.a, -2, -1, 0, 1, 2, 3, 4, 5, 6)) +TableReader 1.00 root partition:all data:Selection +└─Selection 1.00 cop[tikv] not(in(executor__partition__partition_boundaries.t.a, -2, -1, 0, 1, 2, 3, 4, 5, 6)) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1, 2, 3, 4, 5, 6); a b @@ -671,15 +671,15 @@ a b 6 6 Filler... explain format='brief' SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1 AND a != 2 AND a != 3 AND a != 4 AND a != 5 AND a != 6 AND a != 7; id estRows task access object operator info -TableReader 0.00 root partition:all data:Selection -└─Selection 0.00 cop[tikv] ne(executor__partition__partition_boundaries.t.a, -1), ne(executor__partition__partition_boundaries.t.a, 0), ne(executor__partition__partition_boundaries.t.a, 1), ne(executor__partition__partition_boundaries.t.a, 2), ne(executor__partition__partition_boundaries.t.a, 3), ne(executor__partition__partition_boundaries.t.a, 4), ne(executor__partition__partition_boundaries.t.a, 5), ne(executor__partition__partition_boundaries.t.a, 6), ne(executor__partition__partition_boundaries.t.a, 7) +TableReader 1.00 root partition:all data:Selection +└─Selection 1.00 cop[tikv] ne(executor__partition__partition_boundaries.t.a, -1), ne(executor__partition__partition_boundaries.t.a, 0), ne(executor__partition__partition_boundaries.t.a, 1), ne(executor__partition__partition_boundaries.t.a, 2), ne(executor__partition__partition_boundaries.t.a, 3), ne(executor__partition__partition_boundaries.t.a, 4), ne(executor__partition__partition_boundaries.t.a, 5), ne(executor__partition__partition_boundaries.t.a, 6), ne(executor__partition__partition_boundaries.t.a, 7) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE 1 = 1 AND a != -1 AND a != 0 AND a != 1 AND a != 2 AND a != 3 AND a != 4 AND a != 5 AND a != 6 AND a != 7; a b explain format='brief' SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1, 2, 3, 4, 5, 6, 7); id estRows task access object operator info -TableReader 0.00 root partition:all data:Selection -└─Selection 0.00 cop[tikv] not(in(executor__partition__partition_boundaries.t.a, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7)) +TableReader 1.00 root partition:all data:Selection +└─Selection 1.00 cop[tikv] not(in(executor__partition__partition_boundaries.t.a, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7)) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a NOT IN (-2, -1, 0, 1, 2, 3, 4, 5, 6, 7); a b @@ -712,8 +712,8 @@ INSERT INTO t VALUES (-2147483648, 'MIN_INT filler...'), (0, '0 Filler...'); ANALYZE TABLE t all columns; explain format='brief' SELECT * FROM t WHERE a BETWEEN -2147483648 AND -2147483649; id estRows task access object operator info -TableReader 0.00 root partition:p0 data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, -2147483648), le(executor__partition__partition_boundaries.t.a, -2147483649) +TableReader 1.00 root partition:p0 data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, -2147483648), le(executor__partition__partition_boundaries.t.a, -2147483649) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN -2147483648 AND -2147483649; a b @@ -791,8 +791,8 @@ a b -2147483648 MIN_INT filler... explain format='brief' SELECT * FROM t WHERE a BETWEEN 0 AND -1; id estRows task access object operator info -TableReader 0.00 root partition:p0 data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 0), le(executor__partition__partition_boundaries.t.a, -1) +TableReader 1.00 root partition:p0 data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 0), le(executor__partition__partition_boundaries.t.a, -1) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 0 AND -1; a b @@ -885,8 +885,8 @@ a b 999999 999999 Filler ... explain format='brief' SELECT * FROM t WHERE a BETWEEN 999998 AND 999997; id estRows task access object operator info -TableReader 0.00 root partition:p0 data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 999998), le(executor__partition__partition_boundaries.t.a, 999997) +TableReader 1.00 root partition:p0 data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 999998), le(executor__partition__partition_boundaries.t.a, 999997) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 999998 AND 999997; a b @@ -997,8 +997,8 @@ a b 999999 999999 Filler ... explain format='brief' SELECT * FROM t WHERE a BETWEEN 999999 AND 999998; id estRows task access object operator info -TableReader 0.00 root partition:p0 data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 999999), le(executor__partition__partition_boundaries.t.a, 999998) +TableReader 1.00 root partition:p0 data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 999999), le(executor__partition__partition_boundaries.t.a, 999998) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 999999 AND 999998; a b @@ -1107,8 +1107,8 @@ a b 999999 999999 Filler ... explain format='brief' SELECT * FROM t WHERE a BETWEEN 1000000 AND 999999; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 1000000), le(executor__partition__partition_boundaries.t.a, 999999) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 1000000), le(executor__partition__partition_boundaries.t.a, 999999) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 1000000 AND 999999; a b @@ -1216,8 +1216,8 @@ a b 2000002 2000002 Filler ... explain format='brief' SELECT * FROM t WHERE a BETWEEN 1000001 AND 1000000; id estRows task access object operator info -TableReader 0.00 root partition:p1 data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 1000001), le(executor__partition__partition_boundaries.t.a, 1000000) +TableReader 1.00 root partition:p1 data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 1000001), le(executor__partition__partition_boundaries.t.a, 1000000) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 1000001 AND 1000000; a b @@ -1322,8 +1322,8 @@ a b 2000002 2000002 Filler ... explain format='brief' SELECT * FROM t WHERE a BETWEEN 1000002 AND 1000001; id estRows task access object operator info -TableReader 0.00 root partition:p1 data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 1000002), le(executor__partition__partition_boundaries.t.a, 1000001) +TableReader 1.00 root partition:p1 data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 1000002), le(executor__partition__partition_boundaries.t.a, 1000001) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 1000002 AND 1000001; a b @@ -1423,141 +1423,141 @@ a b 2000002 2000002 Filler ... explain format='brief' SELECT * FROM t WHERE a BETWEEN 3000000 AND 2999999; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000000), le(executor__partition__partition_boundaries.t.a, 2999999) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000000), le(executor__partition__partition_boundaries.t.a, 2999999) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 3000000 AND 2999999; a b explain format='brief' SELECT * FROM t WHERE a BETWEEN 3000000 AND 3000000; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000000), le(executor__partition__partition_boundaries.t.a, 3000000) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000000), le(executor__partition__partition_boundaries.t.a, 3000000) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 3000000 AND 3000000; a b explain format='brief' SELECT * FROM t WHERE a BETWEEN 3000000 AND 3000001; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000000), le(executor__partition__partition_boundaries.t.a, 3000001) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000000), le(executor__partition__partition_boundaries.t.a, 3000001) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 3000000 AND 3000001; a b explain format='brief' SELECT * FROM t WHERE a BETWEEN 3000000 AND 3000002; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000000), le(executor__partition__partition_boundaries.t.a, 3000002) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000000), le(executor__partition__partition_boundaries.t.a, 3000002) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 3000000 AND 3000002; a b explain format='brief' SELECT * FROM t WHERE a BETWEEN 3000000 AND 3000010; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000000), le(executor__partition__partition_boundaries.t.a, 3000010) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000000), le(executor__partition__partition_boundaries.t.a, 3000010) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 3000000 AND 3000010; a b explain format='brief' SELECT * FROM t WHERE a BETWEEN 3000000 AND 3999998; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000000), le(executor__partition__partition_boundaries.t.a, 3999998) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000000), le(executor__partition__partition_boundaries.t.a, 3999998) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 3000000 AND 3999998; a b explain format='brief' SELECT * FROM t WHERE a BETWEEN 3000000 AND 3999999; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000000), le(executor__partition__partition_boundaries.t.a, 3999999) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000000), le(executor__partition__partition_boundaries.t.a, 3999999) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 3000000 AND 3999999; a b explain format='brief' SELECT * FROM t WHERE a BETWEEN 3000000 AND 4000000; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000000), le(executor__partition__partition_boundaries.t.a, 4000000) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000000), le(executor__partition__partition_boundaries.t.a, 4000000) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 3000000 AND 4000000; a b explain format='brief' SELECT * FROM t WHERE a BETWEEN 3000000 AND 4000001; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000000), le(executor__partition__partition_boundaries.t.a, 4000001) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000000), le(executor__partition__partition_boundaries.t.a, 4000001) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 3000000 AND 4000001; a b explain format='brief' SELECT * FROM t WHERE a BETWEEN 3000000 AND 4000002; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000000), le(executor__partition__partition_boundaries.t.a, 4000002) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000000), le(executor__partition__partition_boundaries.t.a, 4000002) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 3000000 AND 4000002; a b explain format='brief' SELECT * FROM t WHERE a BETWEEN 3000001 AND 3000000; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000001), le(executor__partition__partition_boundaries.t.a, 3000000) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000001), le(executor__partition__partition_boundaries.t.a, 3000000) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 3000001 AND 3000000; a b explain format='brief' SELECT * FROM t WHERE a BETWEEN 3000001 AND 3000001; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000001), le(executor__partition__partition_boundaries.t.a, 3000001) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000001), le(executor__partition__partition_boundaries.t.a, 3000001) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 3000001 AND 3000001; a b explain format='brief' SELECT * FROM t WHERE a BETWEEN 3000001 AND 3000002; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000001), le(executor__partition__partition_boundaries.t.a, 3000002) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000001), le(executor__partition__partition_boundaries.t.a, 3000002) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 3000001 AND 3000002; a b explain format='brief' SELECT * FROM t WHERE a BETWEEN 3000001 AND 3000003; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000001), le(executor__partition__partition_boundaries.t.a, 3000003) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000001), le(executor__partition__partition_boundaries.t.a, 3000003) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 3000001 AND 3000003; a b explain format='brief' SELECT * FROM t WHERE a BETWEEN 3000001 AND 3000011; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000001), le(executor__partition__partition_boundaries.t.a, 3000011) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000001), le(executor__partition__partition_boundaries.t.a, 3000011) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 3000001 AND 3000011; a b explain format='brief' SELECT * FROM t WHERE a BETWEEN 3000001 AND 3999999; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000001), le(executor__partition__partition_boundaries.t.a, 3999999) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000001), le(executor__partition__partition_boundaries.t.a, 3999999) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 3000001 AND 3999999; a b explain format='brief' SELECT * FROM t WHERE a BETWEEN 3000001 AND 4000000; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000001), le(executor__partition__partition_boundaries.t.a, 4000000) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000001), le(executor__partition__partition_boundaries.t.a, 4000000) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 3000001 AND 4000000; a b explain format='brief' SELECT * FROM t WHERE a BETWEEN 3000001 AND 4000001; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000001), le(executor__partition__partition_boundaries.t.a, 4000001) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000001), le(executor__partition__partition_boundaries.t.a, 4000001) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 3000001 AND 4000001; a b explain format='brief' SELECT * FROM t WHERE a BETWEEN 3000001 AND 4000002; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000001), le(executor__partition__partition_boundaries.t.a, 4000002) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000001), le(executor__partition__partition_boundaries.t.a, 4000002) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 3000001 AND 4000002; a b explain format='brief' SELECT * FROM t WHERE a BETWEEN 3000001 AND 4000003; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000001), le(executor__partition__partition_boundaries.t.a, 4000003) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000001), le(executor__partition__partition_boundaries.t.a, 4000003) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 3000001 AND 4000003; a b @@ -1582,8 +1582,8 @@ INSERT INTO t VALUES (6, '6 Filler...'); ANALYZE TABLE t all columns; explain format='brief' SELECT * FROM t WHERE a BETWEEN 2 AND -1; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, -1) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, -1) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 2 AND -1; a b @@ -1601,8 +1601,8 @@ a b 4 4 Filler... explain format='brief' SELECT * FROM t WHERE a BETWEEN 2 AND 0; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, 0) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, 0) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 2 AND 0; a b @@ -1620,8 +1620,8 @@ a b 4 4 Filler... explain format='brief' SELECT * FROM t WHERE a BETWEEN 2 AND 1; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, 1) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, 1) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 2 AND 1; a b @@ -1703,8 +1703,8 @@ a b 5 5 Filler... explain format='brief' SELECT * FROM t WHERE a BETWEEN 5 AND 4; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 5), le(executor__partition__partition_boundaries.t.a, 4) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 5), le(executor__partition__partition_boundaries.t.a, 4) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 5 AND 4; a b @@ -1722,8 +1722,8 @@ a b 6 6 Filler... explain format='brief' SELECT * FROM t WHERE a BETWEEN 6 AND 4; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 6), le(executor__partition__partition_boundaries.t.a, 4) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 6), le(executor__partition__partition_boundaries.t.a, 4) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 6 AND 4; a b @@ -1741,8 +1741,8 @@ a b 6 6 Filler... explain format='brief' SELECT * FROM t WHERE a BETWEEN 7 AND 4; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 7), le(executor__partition__partition_boundaries.t.a, 4) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 7), le(executor__partition__partition_boundaries.t.a, 4) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a BETWEEN 7 AND 4; a b @@ -1761,8 +1761,8 @@ INSERT INTO t VALUES (-2147483648, 'MIN_INT filler...'), (0, '0 Filler...'); ANALYZE TABLE t all columns; explain format='brief' SELECT * FROM t WHERE a < -2147483648; id estRows task access object operator info -TableReader 0.00 root partition:p0 data:Selection -└─Selection 0.00 cop[tikv] lt(executor__partition__partition_boundaries.t.a, -2147483648) +TableReader 1.00 root partition:p0 data:Selection +└─Selection 1.00 cop[tikv] lt(executor__partition__partition_boundaries.t.a, -2147483648) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a < -2147483648; a b @@ -2174,8 +2174,8 @@ a b 999999 999999 Filler ... explain format='brief' SELECT * FROM t WHERE a > 3000000; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 3000000) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 3000000) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a > 3000000; a b @@ -2202,8 +2202,8 @@ a b 999999 999999 Filler ... explain format='brief' SELECT * FROM t WHERE a >= 3000000; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000000) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000000) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a >= 3000000; a b @@ -2230,8 +2230,8 @@ a b 999999 999999 Filler ... explain format='brief' SELECT * FROM t WHERE a > 3000001; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 3000001) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 3000001) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a > 3000001; a b @@ -2258,8 +2258,8 @@ a b 999999 999999 Filler ... explain format='brief' SELECT * FROM t WHERE a >= 3000001; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000001) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000001) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a >= 3000001; a b @@ -3199,8 +3199,8 @@ a b 999999 999999 Filler ... explain format='brief' SELECT * FROM t WHERE a > 2999999; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 2999999) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 2999999) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a > 2999999; a b @@ -3243,22 +3243,22 @@ a b 2999999 2999999 Filler ... explain format='brief' SELECT * FROM t WHERE a > 2999999 AND a <= 3000001; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 2999999), le(executor__partition__partition_boundaries.t.a, 3000001) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 2999999), le(executor__partition__partition_boundaries.t.a, 3000001) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a > 2999999 AND a <= 3000001; a b explain format='brief' SELECT * FROM t WHERE a > 2999999 AND a < 3000001; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 2999999), lt(executor__partition__partition_boundaries.t.a, 3000001) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 2999999), lt(executor__partition__partition_boundaries.t.a, 3000001) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a > 2999999 AND a < 3000001; a b explain format='brief' SELECT * FROM t WHERE a > 2999999 AND a <= 3000001; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 2999999), le(executor__partition__partition_boundaries.t.a, 3000001) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 2999999), le(executor__partition__partition_boundaries.t.a, 3000001) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a > 2999999 AND a <= 3000001; a b @@ -3285,8 +3285,8 @@ a b 999999 999999 Filler ... explain format='brief' SELECT * FROM t WHERE a > 3000000; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 3000000) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 3000000) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a > 3000000; a b @@ -3313,36 +3313,36 @@ a b 999999 999999 Filler ... explain format='brief' SELECT * FROM t WHERE a >= 3000000; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000000) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000000) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a >= 3000000; a b explain format='brief' SELECT * FROM t WHERE a >= 3000000 AND a <= 3000002; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000000), le(executor__partition__partition_boundaries.t.a, 3000002) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 3000000), le(executor__partition__partition_boundaries.t.a, 3000002) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a >= 3000000 AND a <= 3000002; a b explain format='brief' SELECT * FROM t WHERE a > 3000000 AND a <= 3000002; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 3000000), le(executor__partition__partition_boundaries.t.a, 3000002) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 3000000), le(executor__partition__partition_boundaries.t.a, 3000002) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a > 3000000 AND a <= 3000002; a b explain format='brief' SELECT * FROM t WHERE a > 3000000 AND a < 3000002; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 3000000), lt(executor__partition__partition_boundaries.t.a, 3000002) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 3000000), lt(executor__partition__partition_boundaries.t.a, 3000002) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a > 3000000 AND a < 3000002; a b explain format='brief' SELECT * FROM t WHERE a > 3000000 AND a <= 3000002; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 3000000), le(executor__partition__partition_boundaries.t.a, 3000002) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 3000000), le(executor__partition__partition_boundaries.t.a, 3000002) └─TableFullScan 14.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a > 3000000 AND a <= 3000002; a b @@ -3369,8 +3369,8 @@ INSERT INTO t VALUES (6, '6 Filler...'); ANALYZE TABLE t all columns; explain format='brief' SELECT * FROM t WHERE a < -1; id estRows task access object operator info -TableReader 0.00 root partition:p0 data:Selection -└─Selection 0.00 cop[tikv] lt(executor__partition__partition_boundaries.t.a, -1) +TableReader 1.00 root partition:p0 data:Selection +└─Selection 1.00 cop[tikv] lt(executor__partition__partition_boundaries.t.a, -1) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a < -1; a b @@ -3390,8 +3390,8 @@ a b 6 6 Filler... explain format='brief' SELECT * FROM t WHERE a <= -1; id estRows task access object operator info -TableReader 0.00 root partition:p0 data:Selection -└─Selection 0.00 cop[tikv] le(executor__partition__partition_boundaries.t.a, -1) +TableReader 1.00 root partition:p0 data:Selection +└─Selection 1.00 cop[tikv] le(executor__partition__partition_boundaries.t.a, -1) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a <= -1; a b @@ -3425,15 +3425,15 @@ a b 6 6 Filler... explain format='brief' SELECT * FROM t WHERE a > 2 AND a < -1; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, -1) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, -1) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a > 2 AND a < -1; a b explain format='brief' SELECT * FROM t WHERE NOT (a < 2 OR a > -1); id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] and(ge(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, -1)) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] and(ge(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, -1)) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE NOT (a < 2 OR a > -1); a b @@ -3467,15 +3467,15 @@ a b 6 6 Filler... explain format='brief' SELECT * FROM t WHERE a >= 2 AND a < -1; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, -1) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, -1) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a >= 2 AND a < -1; a b explain format='brief' SELECT * FROM t WHERE NOT (a < 2 OR a >= -1); id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] and(ge(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, -1)) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] and(ge(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, -1)) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE NOT (a < 2 OR a >= -1); a b @@ -3509,15 +3509,15 @@ a b 6 6 Filler... explain format='brief' SELECT * FROM t WHERE a > 2 AND a <= -1; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, -1) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, -1) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a > 2 AND a <= -1; a b explain format='brief' SELECT * FROM t WHERE NOT (a <= 2 OR a > -1); id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] and(gt(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, -1)) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] and(gt(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, -1)) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE NOT (a <= 2 OR a > -1); a b @@ -3551,15 +3551,15 @@ a b 6 6 Filler... explain format='brief' SELECT * FROM t WHERE a >= 2 AND a <= -1; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, -1) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, -1) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a >= 2 AND a <= -1; a b explain format='brief' SELECT * FROM t WHERE NOT (a <= 2 OR a >= -1); id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] and(gt(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, -1)) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] and(gt(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, -1)) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE NOT (a <= 2 OR a >= -1); a b @@ -3579,8 +3579,8 @@ a b 6 6 Filler... explain format='brief' SELECT * FROM t WHERE a < 0; id estRows task access object operator info -TableReader 0.00 root partition:p0 data:Selection -└─Selection 0.00 cop[tikv] lt(executor__partition__partition_boundaries.t.a, 0) +TableReader 1.00 root partition:p0 data:Selection +└─Selection 1.00 cop[tikv] lt(executor__partition__partition_boundaries.t.a, 0) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a < 0; a b @@ -3635,15 +3635,15 @@ a b 6 6 Filler... explain format='brief' SELECT * FROM t WHERE a > 2 AND a < 0; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, 0) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, 0) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a > 2 AND a < 0; a b explain format='brief' SELECT * FROM t WHERE NOT (a < 2 OR a > 0); id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] and(ge(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, 0)) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] and(ge(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, 0)) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE NOT (a < 2 OR a > 0); a b @@ -3677,15 +3677,15 @@ a b 6 6 Filler... explain format='brief' SELECT * FROM t WHERE a >= 2 AND a < 0; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, 0) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, 0) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a >= 2 AND a < 0; a b explain format='brief' SELECT * FROM t WHERE NOT (a < 2 OR a >= 0); id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] and(ge(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, 0)) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] and(ge(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, 0)) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE NOT (a < 2 OR a >= 0); a b @@ -3719,15 +3719,15 @@ a b 6 6 Filler... explain format='brief' SELECT * FROM t WHERE a > 2 AND a <= 0; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, 0) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, 0) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a > 2 AND a <= 0; a b explain format='brief' SELECT * FROM t WHERE NOT (a <= 2 OR a > 0); id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] and(gt(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, 0)) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] and(gt(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, 0)) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE NOT (a <= 2 OR a > 0); a b @@ -3761,15 +3761,15 @@ a b 6 6 Filler... explain format='brief' SELECT * FROM t WHERE a >= 2 AND a <= 0; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, 0) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, 0) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a >= 2 AND a <= 0; a b explain format='brief' SELECT * FROM t WHERE NOT (a <= 2 OR a >= 0); id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] and(gt(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, 0)) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] and(gt(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, 0)) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE NOT (a <= 2 OR a >= 0); a b @@ -3845,15 +3845,15 @@ a b 6 6 Filler... explain format='brief' SELECT * FROM t WHERE a > 2 AND a < 1; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, 1) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, 1) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a > 2 AND a < 1; a b explain format='brief' SELECT * FROM t WHERE NOT (a < 2 OR a > 1); id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] and(ge(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, 1)) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] and(ge(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, 1)) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE NOT (a < 2 OR a > 1); a b @@ -3887,15 +3887,15 @@ a b 6 6 Filler... explain format='brief' SELECT * FROM t WHERE a >= 2 AND a < 1; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, 1) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, 1) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a >= 2 AND a < 1; a b explain format='brief' SELECT * FROM t WHERE NOT (a < 2 OR a >= 1); id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] and(ge(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, 1)) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] and(ge(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, 1)) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE NOT (a < 2 OR a >= 1); a b @@ -3929,15 +3929,15 @@ a b 6 6 Filler... explain format='brief' SELECT * FROM t WHERE a > 2 AND a <= 1; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, 1) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, 1) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a > 2 AND a <= 1; a b explain format='brief' SELECT * FROM t WHERE NOT (a <= 2 OR a > 1); id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] and(gt(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, 1)) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] and(gt(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, 1)) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE NOT (a <= 2 OR a > 1); a b @@ -3971,15 +3971,15 @@ a b 6 6 Filler... explain format='brief' SELECT * FROM t WHERE a >= 2 AND a <= 1; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, 1) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, 1) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a >= 2 AND a <= 1; a b explain format='brief' SELECT * FROM t WHERE NOT (a <= 2 OR a >= 1); id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] and(gt(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, 1)) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] and(gt(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, 1)) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE NOT (a <= 2 OR a >= 1); a b @@ -4054,8 +4054,8 @@ a b 6 6 Filler... explain format='brief' SELECT * FROM t WHERE a > 2 AND a < 2; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, 2) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, 2) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a > 2 AND a < 2; a b @@ -4097,15 +4097,15 @@ a b 6 6 Filler... explain format='brief' SELECT * FROM t WHERE a >= 2 AND a < 2; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, 2) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, 2) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a >= 2 AND a < 2; a b explain format='brief' SELECT * FROM t WHERE NOT (a < 2 OR a >= 2); id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] and(ge(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, 2)) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] and(ge(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, 2)) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE NOT (a < 2 OR a >= 2); a b @@ -4139,15 +4139,15 @@ a b 6 6 Filler... explain format='brief' SELECT * FROM t WHERE a > 2 AND a <= 2; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, 2) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, 2) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a > 2 AND a <= 2; a b explain format='brief' SELECT * FROM t WHERE NOT (a <= 2 OR a > 2); id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] and(gt(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, 2)) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] and(gt(executor__partition__partition_boundaries.t.a, 2), le(executor__partition__partition_boundaries.t.a, 2)) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE NOT (a <= 2 OR a > 2); a b @@ -4189,8 +4189,8 @@ a b 2 2 Filler... explain format='brief' SELECT * FROM t WHERE NOT (a <= 2 OR a >= 2); id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] and(gt(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, 2)) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] and(gt(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, 2)) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE NOT (a <= 2 OR a >= 2); a b @@ -4263,8 +4263,8 @@ a b 6 6 Filler... explain format='brief' SELECT * FROM t WHERE a > 2 AND a < 3; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, 3) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, 3) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a > 2 AND a < 3; a b @@ -4400,8 +4400,8 @@ a b 3 3 Filler... explain format='brief' SELECT * FROM t WHERE NOT (a <= 2 OR a >= 3); id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] and(gt(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, 3)) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] and(gt(executor__partition__partition_boundaries.t.a, 2), lt(executor__partition__partition_boundaries.t.a, 3)) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE NOT (a <= 2 OR a >= 3); a b @@ -4852,8 +4852,8 @@ a b 5 5 Filler... explain format='brief' SELECT * FROM t WHERE a > 6; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 6) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 6) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a > 6; a b @@ -5063,8 +5063,8 @@ a b 6 6 Filler... explain format='brief' SELECT * FROM t WHERE a > 7; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 7) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] gt(executor__partition__partition_boundaries.t.a, 7) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a > 7; a b @@ -5084,8 +5084,8 @@ a b 6 6 Filler... explain format='brief' SELECT * FROM t WHERE a >= 7; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 7) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] ge(executor__partition__partition_boundaries.t.a, 7) └─TableFullScan 7.00 cop[tikv] table:t keep order:false SELECT * FROM t WHERE a >= 7; a b diff --git a/tests/integrationtest/r/executor/partition/partition_with_expression.result b/tests/integrationtest/r/executor/partition/partition_with_expression.result index 9ba24d016ecd1..81c168a8d0bc1 100644 --- a/tests/integrationtest/r/executor/partition/partition_with_expression.result +++ b/tests/integrationtest/r/executor/partition/partition_with_expression.result @@ -184,8 +184,8 @@ analyze table tp all columns; analyze table t all columns; explain select * from tp where a < '10'; id estRows task access object operator info -TableReader_7 0.00 root partition:p0 data:Selection_6 -└─Selection_6 0.00 cop[tikv] lt(executor__partition__partition_with_expression.tp.a, "10") +TableReader_7 1.00 root partition:p0 data:Selection_6 +└─Selection_6 1.00 cop[tikv] lt(executor__partition__partition_with_expression.tp.a, "10") └─TableFullScan_5 6.00 cop[tikv] table:tp keep order:false select * from tp where a < '10'; a b @@ -274,15 +274,15 @@ SELECT * from t where a = -1; a b explain format='brief' select * from trange where a = -1; id estRows task access object operator info -TableReader 0.00 root partition:p0 data:Selection -└─Selection 0.00 cop[tikv] eq(executor__partition__partition_with_expression.trange.a, -1) +TableReader 1.00 root partition:p0 data:Selection +└─Selection 1.00 cop[tikv] eq(executor__partition__partition_with_expression.trange.a, -1) └─TableFullScan 13.00 cop[tikv] table:trange keep order:false SELECT * from trange where a = -1; a b explain format='brief' select * from thash where a = -1; id estRows task access object operator info -TableReader 0.00 root partition:p1 data:Selection -└─Selection 0.00 cop[tikv] eq(executor__partition__partition_with_expression.thash.a, -1) +TableReader 1.00 root partition:p1 data:Selection +└─Selection 1.00 cop[tikv] eq(executor__partition__partition_with_expression.thash.a, -1) └─TableFullScan 13.00 cop[tikv] table:thash keep order:false SELECT * from thash where a = -1; a b @@ -411,15 +411,15 @@ SELECT * from t where a > 10; a b explain format='brief' select * from trange where a > 10; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] gt(executor__partition__partition_with_expression.trange.a, 10) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] gt(executor__partition__partition_with_expression.trange.a, 10) └─TableFullScan 13.00 cop[tikv] table:trange keep order:false SELECT * from trange where a > 10; a b explain format='brief' select * from thash where a > 10; id estRows task access object operator info -TableReader 0.00 root partition:all data:Selection -└─Selection 0.00 cop[tikv] gt(executor__partition__partition_with_expression.thash.a, 10) +TableReader 1.00 root partition:all data:Selection +└─Selection 1.00 cop[tikv] gt(executor__partition__partition_with_expression.thash.a, 10) └─TableFullScan 13.00 cop[tikv] table:thash keep order:false SELECT * from thash where a > 10; a b @@ -1219,15 +1219,15 @@ SELECT * from t where a > '10'; a b explain format='brief' select * from trange where a > '10'; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] gt(executor__partition__partition_with_expression.trange.a, 10) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] gt(executor__partition__partition_with_expression.trange.a, 10) └─TableFullScan 13.00 cop[tikv] table:trange keep order:false SELECT * from trange where a > '10'; a b explain format='brief' select * from thash where a > '10'; id estRows task access object operator info -TableReader 0.00 root partition:all data:Selection -└─Selection 0.00 cop[tikv] gt(executor__partition__partition_with_expression.thash.a, 10) +TableReader 1.00 root partition:all data:Selection +└─Selection 1.00 cop[tikv] gt(executor__partition__partition_with_expression.thash.a, 10) └─TableFullScan 13.00 cop[tikv] table:thash keep order:false SELECT * from thash where a > '10'; a b @@ -1235,15 +1235,15 @@ SELECT * from t where a > '10ab'; a b explain format='brief' select * from trange where a > '10ab'; id estRows task access object operator info -TableReader 0.00 root partition:dual data:Selection -└─Selection 0.00 cop[tikv] gt(executor__partition__partition_with_expression.trange.a, 10) +TableReader 1.00 root partition:dual data:Selection +└─Selection 1.00 cop[tikv] gt(executor__partition__partition_with_expression.trange.a, 10) └─TableFullScan 13.00 cop[tikv] table:trange keep order:false SELECT * from trange where a > '10ab'; a b explain format='brief' select * from thash where a > '10ab'; id estRows task access object operator info -TableReader 0.00 root partition:all data:Selection -└─Selection 0.00 cop[tikv] gt(executor__partition__partition_with_expression.thash.a, 10) +TableReader 1.00 root partition:all data:Selection +└─Selection 1.00 cop[tikv] gt(executor__partition__partition_with_expression.thash.a, 10) └─TableFullScan 13.00 cop[tikv] table:thash keep order:false SELECT * from thash where a > '10ab'; a b diff --git a/tests/integrationtest/r/explain_easy.result b/tests/integrationtest/r/explain_easy.result index f5a81937ce990..c9e5771dfc0c6 100644 --- a/tests/integrationtest/r/explain_easy.result +++ b/tests/integrationtest/r/explain_easy.result @@ -739,8 +739,8 @@ insert into t values (1),(2),(2),(2),(9),(9),(9),(10); analyze table t all columns with 1 buckets; explain format = 'brief' select * from t where a >= 3 and a <= 8; id estRows task access object operator info -TableReader 0.00 root data:Selection -└─Selection 0.00 cop[tikv] ge(explain_easy.t.a, 3), le(explain_easy.t.a, 8) +TableReader 1.00 root data:Selection +└─Selection 1.00 cop[tikv] ge(explain_easy.t.a, 3), le(explain_easy.t.a, 8) └─TableFullScan 8.00 cop[tikv] table:t keep order:false drop table t; create table t(a int, b int, index idx_ab(a, b)); diff --git a/tests/integrationtest/r/explain_generate_column_substitute.result b/tests/integrationtest/r/explain_generate_column_substitute.result index 53a02de94d8d5..6732ab8473fa0 100644 --- a/tests/integrationtest/r/explain_generate_column_substitute.result +++ b/tests/integrationtest/r/explain_generate_column_substitute.result @@ -413,10 +413,10 @@ Projection 1.00 root explain_generate_column_substitute.t.a, explain_generate_c └─TableRowIDScan(Probe) 1.00 cop[tikv] table:t keep order:false desc format = 'brief' select * from t where not (lower(b) >= "a"); id estRows task access object operator info -Projection 0.00 root explain_generate_column_substitute.t.a, explain_generate_column_substitute.t.b -└─IndexLookUp 0.00 root - ├─IndexRangeScan(Build) 0.00 cop[tikv] table:t, index:expression_index(lower(`b`), `a` + 1) range:[-inf,"a"), keep order:false - └─TableRowIDScan(Probe) 0.00 cop[tikv] table:t keep order:false +Projection 1.00 root explain_generate_column_substitute.t.a, explain_generate_column_substitute.t.b +└─IndexLookUp 1.00 root + ├─IndexRangeScan(Build) 1.00 cop[tikv] table:t, index:expression_index(lower(`b`), `a` + 1) range:[-inf,"a"), keep order:false + └─TableRowIDScan(Probe) 1.00 cop[tikv] table:t keep order:false desc format = 'brief' select count(upper(b)) from t group by upper(b); id estRows task access object operator info StreamAgg 4.80 root group by:upper(explain_generate_column_substitute.t.b), funcs:count(upper(explain_generate_column_substitute.t.b))->Column#7 diff --git a/tests/integrationtest/r/imdbload.result b/tests/integrationtest/r/imdbload.result index 7e5914344f1bf..2642b0837296c 100644 --- a/tests/integrationtest/r/imdbload.result +++ b/tests/integrationtest/r/imdbload.result @@ -286,48 +286,48 @@ IndexLookUp_7 1005030.94 root └─TableRowIDScan_6(Probe) 1005030.94 cop[tikv] table:char_name keep order:false trace plan target = 'estimation' select * from char_name where ((imdb_index = 'I') and (surname_pcode < 'E436')) or ((imdb_index = 'L') and (surname_pcode < 'E436')); CE_trace -[{"table_name":"char_name","type":"Column Stats-Point","expr":"((imdb_index = 'I'))","row_count":0},{"table_name":"char_name","type":"Column Stats-Point","expr":"((imdb_index = 'L'))","row_count":0},{"table_name":"char_name","type":"Column Stats-Range","expr":"((id >= -9223372036854775808 and id <= 9223372036854775807))","row_count":4314864},{"table_name":"char_name","type":"Column Stats-Range","expr":"((surname_pcode < 'E436'))","row_count":1005030},{"table_name":"char_name","type":"Index Stats-Range","expr":"((imdb_index = 'I') and (surname_pcode < 'E436')) or ((imdb_index = 'L') and (surname_pcode < 'E436'))","row_count":0},{"table_name":"char_name","type":"Index Stats-Range","expr":"((surname_pcode < 'E436'))","row_count":1005030},{"table_name":"char_name","type":"Table Stats-Expression-CNF","expr":"`or`(`and`(`eq`(imdbload.char_name.imdb_index, 'I'), `lt`(imdbload.char_name.surname_pcode, 'E436')), `and`(`eq`(imdbload.char_name.imdb_index, 'L'), `lt`(imdbload.char_name.surname_pcode, 'E436')))","row_count":804024}] +[{"table_name":"char_name","type":"Column Stats-Point","expr":"((imdb_index = 'I'))","row_count":1},{"table_name":"char_name","type":"Column Stats-Point","expr":"((imdb_index = 'L'))","row_count":1},{"table_name":"char_name","type":"Column Stats-Range","expr":"((id >= -9223372036854775808 and id <= 9223372036854775807))","row_count":4314864},{"table_name":"char_name","type":"Column Stats-Range","expr":"((surname_pcode < 'E436'))","row_count":1005030},{"table_name":"char_name","type":"Index Stats-Range","expr":"((imdb_index = 'I') and (surname_pcode < 'E436')) or ((imdb_index = 'L') and (surname_pcode < 'E436'))","row_count":2},{"table_name":"char_name","type":"Index Stats-Range","expr":"((surname_pcode < 'E436'))","row_count":1005030},{"table_name":"char_name","type":"Table Stats-Expression-CNF","expr":"`or`(`and`(`eq`(imdbload.char_name.imdb_index, 'I'), `lt`(imdbload.char_name.surname_pcode, 'E436')), `and`(`eq`(imdbload.char_name.imdb_index, 'L'), `lt`(imdbload.char_name.surname_pcode, 'E436')))","row_count":804024}] explain select * from char_name where ((imdb_index = 'V') and (surname_pcode < 'L3416')); id estRows task access object operator info -IndexLookUp_10 0.00 root -├─IndexRangeScan_8(Build) 0.00 cop[tikv] table:char_name, index:itest2(imdb_index, surname_pcode, name_pcode_nf) range:["V" -inf,"V" "L3416"), keep order:false -└─TableRowIDScan_9(Probe) 0.00 cop[tikv] table:char_name keep order:false +IndexLookUp_10 1.00 root +├─IndexRangeScan_8(Build) 1.00 cop[tikv] table:char_name, index:itest2(imdb_index, surname_pcode, name_pcode_nf) range:["V" -inf,"V" "L3416"), keep order:false +└─TableRowIDScan_9(Probe) 1.00 cop[tikv] table:char_name keep order:false explain select * from char_name where imdb_index > 'V'; id estRows task access object operator info -IndexLookUp_10 0.00 root -├─IndexRangeScan_8(Build) 0.00 cop[tikv] table:char_name, index:itest2(imdb_index, surname_pcode, name_pcode_nf) range:("V",+inf], keep order:false -└─TableRowIDScan_9(Probe) 0.00 cop[tikv] table:char_name keep order:false +IndexLookUp_10 1.00 root +├─IndexRangeScan_8(Build) 1.00 cop[tikv] table:char_name, index:itest2(imdb_index, surname_pcode, name_pcode_nf) range:("V",+inf], keep order:false +└─TableRowIDScan_9(Probe) 1.00 cop[tikv] table:char_name keep order:false trace plan target = 'estimation' select * from char_name where imdb_index > 'V'; CE_trace -[{"table_name":"char_name","type":"Column Stats-Range","expr":"((id >= -9223372036854775808 and id <= 9223372036854775807))","row_count":4314864},{"table_name":"char_name","type":"Column Stats-Range","expr":"((imdb_index > 'V' and true))","row_count":0},{"table_name":"char_name","type":"Index Stats-Range","expr":"((imdb_index > 'V' and true))","row_count":0},{"table_name":"char_name","type":"Table Stats-Expression-CNF","expr":"`gt`(imdbload.char_name.imdb_index, 'V')","row_count":0}] +[{"table_name":"char_name","type":"Column Stats-Range","expr":"((id >= -9223372036854775808 and id <= 9223372036854775807))","row_count":4314864},{"table_name":"char_name","type":"Column Stats-Range","expr":"((imdb_index > 'V' and true))","row_count":1},{"table_name":"char_name","type":"Index Stats-Range","expr":"((imdb_index > 'V' and true))","row_count":1},{"table_name":"char_name","type":"Table Stats-Expression-CNF","expr":"`gt`(imdbload.char_name.imdb_index, 'V')","row_count":1}] explain select * from movie_companies where company_type_id > 2; id estRows task access object operator info -IndexLookUp_10 0.00 root -├─IndexRangeScan_8(Build) 0.00 cop[tikv] table:movie_companies, index:movie_companies_idx_ctypeid(company_type_id) range:(2,+inf], keep order:false -└─TableRowIDScan_9(Probe) 0.00 cop[tikv] table:movie_companies keep order:false +IndexLookUp_10 1.00 root +├─IndexRangeScan_8(Build) 1.00 cop[tikv] table:movie_companies, index:movie_companies_idx_ctypeid(company_type_id) range:(2,+inf], keep order:false +└─TableRowIDScan_9(Probe) 1.00 cop[tikv] table:movie_companies keep order:false trace plan target = 'estimation' select * from movie_companies where company_type_id > 2; CE_trace -[{"table_name":"movie_companies","type":"Column Stats-Range","expr":"((company_type_id > 2 and true))","row_count":0},{"table_name":"movie_companies","type":"Column Stats-Range","expr":"((id >= -9223372036854775808 and id <= 9223372036854775807))","row_count":4958296},{"table_name":"movie_companies","type":"Index Stats-Range","expr":"((company_type_id > 2 and true))","row_count":0},{"table_name":"movie_companies","type":"Table Stats-Expression-CNF","expr":"`gt`(imdbload.movie_companies.company_type_id, 2)","row_count":0}] +[{"table_name":"movie_companies","type":"Column Stats-Range","expr":"((company_type_id > 2 and true))","row_count":1},{"table_name":"movie_companies","type":"Column Stats-Range","expr":"((id >= -9223372036854775808 and id <= 9223372036854775807))","row_count":4958296},{"table_name":"movie_companies","type":"Index Stats-Range","expr":"((company_type_id > 2 and true))","row_count":1},{"table_name":"movie_companies","type":"Table Stats-Expression-CNF","expr":"`gt`(imdbload.movie_companies.company_type_id, 2)","row_count":1}] explain select * from char_name where imdb_index > 'I' and imdb_index < 'II'; id estRows task access object operator info -IndexLookUp_10 0.00 root -├─IndexRangeScan_8(Build) 0.00 cop[tikv] table:char_name, index:itest2(imdb_index, surname_pcode, name_pcode_nf) range:("I","II"), keep order:false -└─TableRowIDScan_9(Probe) 0.00 cop[tikv] table:char_name keep order:false +IndexLookUp_10 1.00 root +├─IndexRangeScan_8(Build) 1.00 cop[tikv] table:char_name, index:itest2(imdb_index, surname_pcode, name_pcode_nf) range:("I","II"), keep order:false +└─TableRowIDScan_9(Probe) 1.00 cop[tikv] table:char_name keep order:false trace plan target = 'estimation' select * from char_name where imdb_index > 'I' and imdb_index < 'II'; CE_trace -[{"table_name":"char_name","type":"Column Stats-Range","expr":"((id >= -9223372036854775808 and id <= 9223372036854775807))","row_count":4314864},{"table_name":"char_name","type":"Column Stats-Range","expr":"((imdb_index > 'I' and imdb_index < 'II'))","row_count":0},{"table_name":"char_name","type":"Index Stats-Range","expr":"((imdb_index > 'I' and imdb_index < 'II'))","row_count":0},{"table_name":"char_name","type":"Table Stats-Expression-CNF","expr":"`and`(`gt`(imdbload.char_name.imdb_index, 'I'), `lt`(imdbload.char_name.imdb_index, 'II'))","row_count":0}] +[{"table_name":"char_name","type":"Column Stats-Range","expr":"((id >= -9223372036854775808 and id <= 9223372036854775807))","row_count":4314864},{"table_name":"char_name","type":"Column Stats-Range","expr":"((imdb_index > 'I' and imdb_index < 'II'))","row_count":1},{"table_name":"char_name","type":"Index Stats-Range","expr":"((imdb_index > 'I' and imdb_index < 'II'))","row_count":1},{"table_name":"char_name","type":"Table Stats-Expression-CNF","expr":"`and`(`gt`(imdbload.char_name.imdb_index, 'I'), `lt`(imdbload.char_name.imdb_index, 'II'))","row_count":1}] explain select * from char_name where imdb_index > 'I'; id estRows task access object operator info -IndexLookUp_10 0.00 root -├─IndexRangeScan_8(Build) 0.00 cop[tikv] table:char_name, index:itest2(imdb_index, surname_pcode, name_pcode_nf) range:("I",+inf], keep order:false -└─TableRowIDScan_9(Probe) 0.00 cop[tikv] table:char_name keep order:false +IndexLookUp_10 1.00 root +├─IndexRangeScan_8(Build) 1.00 cop[tikv] table:char_name, index:itest2(imdb_index, surname_pcode, name_pcode_nf) range:("I",+inf], keep order:false +└─TableRowIDScan_9(Probe) 1.00 cop[tikv] table:char_name keep order:false trace plan target = 'estimation' select * from char_name where imdb_index > 'I'; CE_trace -[{"table_name":"char_name","type":"Column Stats-Range","expr":"((id >= -9223372036854775808 and id <= 9223372036854775807))","row_count":4314864},{"table_name":"char_name","type":"Column Stats-Range","expr":"((imdb_index > 'I' and true))","row_count":0},{"table_name":"char_name","type":"Index Stats-Range","expr":"((imdb_index > 'I' and true))","row_count":0},{"table_name":"char_name","type":"Table Stats-Expression-CNF","expr":"`gt`(imdbload.char_name.imdb_index, 'I')","row_count":0}] +[{"table_name":"char_name","type":"Column Stats-Range","expr":"((id >= -9223372036854775808 and id <= 9223372036854775807))","row_count":4314864},{"table_name":"char_name","type":"Column Stats-Range","expr":"((imdb_index > 'I' and true))","row_count":1},{"table_name":"char_name","type":"Index Stats-Range","expr":"((imdb_index > 'I' and true))","row_count":1},{"table_name":"char_name","type":"Table Stats-Expression-CNF","expr":"`gt`(imdbload.char_name.imdb_index, 'I')","row_count":1}] explain select * from cast_info where nr_order < -2068070866; id estRows task access object operator info @@ -341,12 +341,12 @@ TableReader_7 34260.33 root data:Selection_6 └─TableFullScan_5 528337.00 cop[tikv] table:aka_title keep order:false explain select * from aka_title where kind_id > 7; id estRows task access object operator info -IndexLookUp_10 0.00 root -├─IndexRangeScan_8(Build) 0.00 cop[tikv] table:aka_title, index:aka_title_idx_kindid(kind_id) range:(7,+inf], keep order:false -└─TableRowIDScan_9(Probe) 0.00 cop[tikv] table:aka_title keep order:false +IndexLookUp_10 1.00 root +├─IndexRangeScan_8(Build) 1.00 cop[tikv] table:aka_title, index:aka_title_idx_kindid(kind_id) range:(7,+inf], keep order:false +└─TableRowIDScan_9(Probe) 1.00 cop[tikv] table:aka_title keep order:false trace plan target = 'estimation' select * from aka_title where kind_id > 7; CE_trace -[{"table_name":"aka_title","type":"Column Stats-Range","expr":"((id >= -9223372036854775808 and id <= 9223372036854775807))","row_count":528337},{"table_name":"aka_title","type":"Column Stats-Range","expr":"((kind_id > 7 and true))","row_count":0},{"table_name":"aka_title","type":"Index Stats-Range","expr":"((kind_id > 7 and true))","row_count":0},{"table_name":"aka_title","type":"Table Stats-Expression-CNF","expr":"`gt`(imdbload.aka_title.kind_id, 7)","row_count":0}] +[{"table_name":"aka_title","type":"Column Stats-Range","expr":"((id >= -9223372036854775808 and id <= 9223372036854775807))","row_count":528337},{"table_name":"aka_title","type":"Column Stats-Range","expr":"((kind_id > 7 and true))","row_count":1},{"table_name":"aka_title","type":"Index Stats-Range","expr":"((kind_id > 7 and true))","row_count":1},{"table_name":"aka_title","type":"Table Stats-Expression-CNF","expr":"`gt`(imdbload.aka_title.kind_id, 7)","row_count":1}] explain select * from keyword where ((phonetic_code = 'R1652') and (keyword > 'ecg-monitor' and keyword < 'killers')); id estRows task access object operator info diff --git a/tests/integrationtest/r/planner/cardinality/selectivity.result b/tests/integrationtest/r/planner/cardinality/selectivity.result index 9ef9acfdcce63..89bcbb5ce9da3 100644 --- a/tests/integrationtest/r/planner/cardinality/selectivity.result +++ b/tests/integrationtest/r/planner/cardinality/selectivity.result @@ -1225,8 +1225,14 @@ insert into t values ('tw', 0); analyze table t all columns; explain select * from t where a = 'tw' and b < 0; id estRows task access object operator info +IndexReader_6 1.00 root index:IndexRangeScan_5 +└─IndexRangeScan_5 1.00 cop[tikv] table:t, index:idx(a, b) range:["tw" -inf,"tw" 0), keep order:false +set @@tidb_opt_fix_control = '47400:on'; +explain select * from t where a = 'tw' and b < 0; +id estRows task access object operator info IndexReader_6 0.00 root index:IndexRangeScan_5 └─IndexRangeScan_5 0.00 cop[tikv] table:t, index:idx(a, b) range:["tw" -inf,"tw" 0), keep order:false +set @@tidb_opt_fix_control = '47400:off'; drop table if exists t; create table t(id int auto_increment, kid int, pid int, primary key(id), key(kid, pid)); insert into t (kid, pid) values (1,2), (1,3), (1,4),(1, 11), (1, 12), (1, 13), (1, 14), (2, 2), (2, 3), (2, 4); diff --git a/tests/integrationtest/r/planner/core/casetest/integration.result b/tests/integrationtest/r/planner/core/casetest/integration.result index 09c6bad54fd27..9946469915370 100644 --- a/tests/integrationtest/r/planner/core/casetest/integration.result +++ b/tests/integrationtest/r/planner/core/casetest/integration.result @@ -1154,17 +1154,17 @@ TableReader_7 3.00 130.42 root data:Selection_6 └─TableFullScan_5 5.00 1136.54 cop[tikv] table:t keep order:false explain format = 'verbose' select * from t where b = 6 order by a limit 1; id estRows estCost task access object operator info -Limit_11 0.00 98.74 root offset:0, count:1 -└─TableReader_24 0.00 98.74 root data:Limit_23 - └─Limit_23 0.00 1386.04 cop[tikv] offset:0, count:1 - └─Selection_22 0.00 1386.04 cop[tikv] eq(planner__core__casetest__integration.t.b, 6) +Limit_11 1.00 98.74 root offset:0, count:1 +└─TableReader_24 1.00 98.74 root data:Limit_23 + └─Limit_23 1.00 1386.04 cop[tikv] offset:0, count:1 + └─Selection_22 1.00 1386.04 cop[tikv] eq(planner__core__casetest__integration.t.b, 6) └─TableFullScan_21 5.00 1136.54 cop[tikv] table:t keep order:true explain format = 'verbose' select * from t where b = 6 limit 1; id estRows estCost task access object operator info -Limit_8 0.00 98.74 root offset:0, count:1 -└─TableReader_13 0.00 98.74 root data:Limit_12 - └─Limit_12 0.00 1386.04 cop[tikv] offset:0, count:1 - └─Selection_11 0.00 1386.04 cop[tikv] eq(planner__core__casetest__integration.t.b, 6) +Limit_8 1.00 98.74 root offset:0, count:1 +└─TableReader_13 1.00 98.74 root data:Limit_12 + └─Limit_12 1.00 1386.04 cop[tikv] offset:0, count:1 + └─Selection_11 1.00 1386.04 cop[tikv] eq(planner__core__casetest__integration.t.b, 6) └─TableFullScan_10 5.00 1136.54 cop[tikv] table:t keep order:false set tidb_opt_prefer_range_scan = 1; explain format = 'verbose' select * from t where b > 5; @@ -1176,19 +1176,19 @@ Level Code Message Note 1105 [idx_b] remain after pruning paths for t given Prop{SortItems: [], TaskTp: rootTask} explain format = 'verbose' select * from t where b = 6 order by a limit 1; id estRows estCost task access object operator info -TopN_9 0.00 1956.63 root planner__core__casetest__integration.t.a, offset:0, count:1 -└─IndexLookUp_16 0.00 1951.83 root - ├─TopN_15(Build) 0.00 206.70 cop[tikv] planner__core__casetest__integration.t.a, offset:0, count:1 - │ └─IndexRangeScan_13 0.00 203.50 cop[tikv] table:t, index:idx_b(b) range:[6,6], keep order:false - └─TableRowIDScan_14(Probe) 0.00 186.61 cop[tikv] table:t keep order:false +TopN_9 1.00 1956.63 root planner__core__casetest__integration.t.a, offset:0, count:1 +└─IndexLookUp_16 1.00 1951.83 root + ├─TopN_15(Build) 1.00 206.70 cop[tikv] planner__core__casetest__integration.t.a, offset:0, count:1 + │ └─IndexRangeScan_13 1.00 203.50 cop[tikv] table:t, index:idx_b(b) range:[6,6], keep order:false + └─TableRowIDScan_14(Probe) 1.00 186.61 cop[tikv] table:t keep order:false Level Code Message Note 1105 [idx_b] remain after pruning paths for t given Prop{SortItems: [], TaskTp: copMultiReadTask} explain format = 'verbose' select * from t where b = 6 limit 1; id estRows estCost task access object operator info -IndexLookUp_13 0.00 1170.97 root limit embedded(offset:0, count:1) -├─Limit_12(Build) 0.00 203.50 cop[tikv] offset:0, count:1 -│ └─IndexRangeScan_10 0.00 203.50 cop[tikv] table:t, index:idx_b(b) range:[6,6], keep order:false -└─TableRowIDScan_11(Probe) 0.00 186.61 cop[tikv] table:t keep order:false +IndexLookUp_13 1.00 1170.97 root limit embedded(offset:0, count:1) +├─Limit_12(Build) 1.00 203.50 cop[tikv] offset:0, count:1 +│ └─IndexRangeScan_10 1.00 203.50 cop[tikv] table:t, index:idx_b(b) range:[6,6], keep order:false +└─TableRowIDScan_11(Probe) 1.00 186.61 cop[tikv] table:t keep order:false Level Code Message Note 1105 [idx_b] remain after pruning paths for t given Prop{SortItems: [], TaskTp: copMultiReadTask} set @@tidb_enable_chunk_rpc = default; diff --git a/tests/integrationtest/r/planner/core/partition_pruner.result b/tests/integrationtest/r/planner/core/partition_pruner.result index 699eab20186e6..039d92a3891d8 100644 --- a/tests/integrationtest/r/planner/core/partition_pruner.result +++ b/tests/integrationtest/r/planner/core/partition_pruner.result @@ -3120,8 +3120,8 @@ IndexReader_10 2.00 root partition:all index:Selection_9 └─IndexFullScan_8 2.00 cop[tikv] table:test1, index:PRIMARY(ID, PARTITION_NO, CREATE_TIME) keep order:false explain select * from test1 where partition_no < 200000; id estRows task access object operator info -IndexReader_10 0.00 root partition:2023p1 index:Selection_9 -└─Selection_9 0.00 cop[tikv] lt(issue43459.test1.partition_no, 200000) +IndexReader_10 1.00 root partition:2023p1 index:Selection_9 +└─Selection_9 1.00 cop[tikv] lt(issue43459.test1.partition_no, 200000) └─IndexFullScan_8 2.00 cop[tikv] table:test1, index:PRIMARY(ID, PARTITION_NO, CREATE_TIME) keep order:false explain select * from test1 where partition_no <= 200000; id estRows task access object operator info @@ -3130,8 +3130,8 @@ IndexReader_10 2.00 root partition:all index:Selection_9 └─IndexFullScan_8 2.00 cop[tikv] table:test1, index:PRIMARY(ID, PARTITION_NO, CREATE_TIME) keep order:false explain select * from test1 where partition_no > 200000; id estRows task access object operator info -IndexReader_10 0.00 root partition:2023p2 index:Selection_9 -└─Selection_9 0.00 cop[tikv] gt(issue43459.test1.partition_no, 200000) +IndexReader_10 1.00 root partition:2023p2 index:Selection_9 +└─Selection_9 1.00 cop[tikv] gt(issue43459.test1.partition_no, 200000) └─IndexFullScan_8 2.00 cop[tikv] table:test1, index:PRIMARY(ID, PARTITION_NO, CREATE_TIME) keep order:false select * from test1 partition (2023p1); ID PARTITION_NO CREATE_TIME @@ -3179,8 +3179,8 @@ IndexReader_10 2.00 root partition:all index:Selection_9 └─IndexFullScan_8 2.00 cop[tikv] table:test1, index:PRIMARY(ID, PARTITION_NO, CREATE_TIME) keep order:false explain select * from test1 where partition_no < 200000; id estRows task access object operator info -IndexReader_10 0.00 root partition:2023p1 index:Selection_9 -└─Selection_9 0.00 cop[tikv] lt(issue43459.test1.partition_no, 200000) +IndexReader_10 1.00 root partition:2023p1 index:Selection_9 +└─Selection_9 1.00 cop[tikv] lt(issue43459.test1.partition_no, 200000) └─IndexFullScan_8 2.00 cop[tikv] table:test1, index:PRIMARY(ID, PARTITION_NO, CREATE_TIME) keep order:false explain select * from test1 where partition_no <= 200000; id estRows task access object operator info @@ -3189,8 +3189,8 @@ IndexReader_10 2.00 root partition:all index:Selection_9 └─IndexFullScan_8 2.00 cop[tikv] table:test1, index:PRIMARY(ID, PARTITION_NO, CREATE_TIME) keep order:false explain select * from test1 where partition_no > 200000; id estRows task access object operator info -IndexReader_10 0.00 root partition:2023p2 index:Selection_9 -└─Selection_9 0.00 cop[tikv] gt(issue43459.test1.partition_no, 200000) +IndexReader_10 1.00 root partition:2023p2 index:Selection_9 +└─Selection_9 1.00 cop[tikv] gt(issue43459.test1.partition_no, 200000) └─IndexFullScan_8 2.00 cop[tikv] table:test1, index:PRIMARY(ID, PARTITION_NO, CREATE_TIME) keep order:false select * from test1 partition (2023p1); ID PARTITION_NO CREATE_TIME diff --git a/tests/integrationtest/r/statistics/integration.result b/tests/integrationtest/r/statistics/integration.result index aa9bb4ac163b9..4baea6abdeeb1 100644 --- a/tests/integrationtest/r/statistics/integration.result +++ b/tests/integrationtest/r/statistics/integration.result @@ -17,8 +17,8 @@ explain format = 'brief' select * from t1 left join t2 on t1.a=t2.a order by t1. id estRows task access object operator info Sort 4.00 root statistics__integration.t1.a, statistics__integration.t2.a └─HashJoin 4.00 root left outer join, equal:[eq(statistics__integration.t1.a, statistics__integration.t2.a)] - ├─TableReader(Build) 0.00 root data:Selection - │ └─Selection 0.00 cop[tikv] not(isnull(statistics__integration.t2.a)) + ├─TableReader(Build) 1.00 root data:Selection + │ └─Selection 1.00 cop[tikv] not(isnull(statistics__integration.t2.a)) │ └─TableFullScan 2.00 cop[tikv] table:t2 keep order:false └─TableReader(Probe) 4.00 root data:TableFullScan └─TableFullScan 4.00 cop[tikv] table:t1 keep order:false @@ -26,8 +26,8 @@ explain format = 'brief' select * from t2 left join t1 on t1.a=t2.a order by t1. id estRows task access object operator info Sort 2.00 root statistics__integration.t1.a, statistics__integration.t2.a └─HashJoin 2.00 root left outer join, equal:[eq(statistics__integration.t2.a, statistics__integration.t1.a)] - ├─TableReader(Build) 0.00 root data:Selection - │ └─Selection 0.00 cop[tikv] not(isnull(statistics__integration.t1.a)) + ├─TableReader(Build) 1.00 root data:Selection + │ └─Selection 1.00 cop[tikv] not(isnull(statistics__integration.t1.a)) │ └─TableFullScan 4.00 cop[tikv] table:t1 keep order:false └─TableReader(Probe) 2.00 root data:TableFullScan └─TableFullScan 2.00 cop[tikv] table:t2 keep order:false @@ -35,8 +35,8 @@ explain format = 'brief' select * from t1 right join t2 on t1.a=t2.a order by t1 id estRows task access object operator info Sort 2.00 root statistics__integration.t1.a, statistics__integration.t2.a └─HashJoin 2.00 root right outer join, equal:[eq(statistics__integration.t1.a, statistics__integration.t2.a)] - ├─TableReader(Build) 0.00 root data:Selection - │ └─Selection 0.00 cop[tikv] not(isnull(statistics__integration.t1.a)) + ├─TableReader(Build) 1.00 root data:Selection + │ └─Selection 1.00 cop[tikv] not(isnull(statistics__integration.t1.a)) │ └─TableFullScan 4.00 cop[tikv] table:t1 keep order:false └─TableReader(Probe) 2.00 root data:TableFullScan └─TableFullScan 2.00 cop[tikv] table:t2 keep order:false @@ -44,8 +44,8 @@ explain format = 'brief' select * from t2 right join t1 on t1.a=t2.a order by t1 id estRows task access object operator info Sort 4.00 root statistics__integration.t1.a, statistics__integration.t2.a └─HashJoin 4.00 root right outer join, equal:[eq(statistics__integration.t2.a, statistics__integration.t1.a)] - ├─TableReader(Build) 0.00 root data:Selection - │ └─Selection 0.00 cop[tikv] not(isnull(statistics__integration.t2.a)) + ├─TableReader(Build) 1.00 root data:Selection + │ └─Selection 1.00 cop[tikv] not(isnull(statistics__integration.t2.a)) │ └─TableFullScan 2.00 cop[tikv] table:t2 keep order:false └─TableReader(Probe) 4.00 root data:TableFullScan └─TableFullScan 4.00 cop[tikv] table:t1 keep order:false diff --git a/tests/integrationtest/r/tpch.result b/tests/integrationtest/r/tpch.result index cd2f96f31ce7c..bdb7c7f740c77 100644 --- a/tests/integrationtest/r/tpch.result +++ b/tests/integrationtest/r/tpch.result @@ -1292,10 +1292,10 @@ id estRows task access object operator info Sort 1.00 root Column#31 └─Projection 1.00 root Column#31, Column#32, Column#33 └─HashAgg 1.00 root group by:Column#36, funcs:count(1)->Column#32, funcs:sum(Column#35)->Column#33, funcs:firstrow(Column#36)->Column#31 - └─Projection 0.00 root tpch50.customer.c_acctbal->Column#35, substring(tpch50.customer.c_phone, 1, 2)->Column#36 - └─HashJoin 0.00 root anti semi join, equal:[eq(tpch50.customer.c_custkey, tpch50.orders.o_custkey)] + └─Projection 0.64 root tpch50.customer.c_acctbal->Column#35, substring(tpch50.customer.c_phone, 1, 2)->Column#36 + └─HashJoin 0.64 root anti semi join, equal:[eq(tpch50.customer.c_custkey, tpch50.orders.o_custkey)] ├─TableReader(Build) 75000000.00 root data:TableFullScan │ └─TableFullScan 75000000.00 cop[tikv] table:orders keep order:false - └─TableReader(Probe) 0.00 root data:Selection - └─Selection 0.00 cop[tikv] gt(tpch50.customer.c_acctbal, NULL), in(substring(tpch50.customer.c_phone, 1, 2), "20", "40", "22", "30", "39", "42", "21") + └─TableReader(Probe) 0.80 root data:Selection + └─Selection 0.80 cop[tikv] gt(tpch50.customer.c_acctbal, NULL), in(substring(tpch50.customer.c_phone, 1, 2), "20", "40", "22", "30", "39", "42", "21") └─TableFullScan 7500000.00 cop[tikv] table:customer keep order:false diff --git a/tests/integrationtest/r/util/ranger.result b/tests/integrationtest/r/util/ranger.result index 7acee71598f07..c6cfef64a3bc3 100644 --- a/tests/integrationtest/r/util/ranger.result +++ b/tests/integrationtest/r/util/ranger.result @@ -195,12 +195,12 @@ select * from t where a = 3; a b explain format='brief' select * from t where a < 1; id estRows task access object operator info -PartitionUnion 1.00 root +PartitionUnion 2.00 root ├─TableReader 1.00 root data:Selection │ └─Selection 1.00 cop[tikv] lt(util__ranger.t.a, 1) │ └─TableFullScan 1.00 cop[tikv] table:t, partition:p0 keep order:false -└─TableReader 0.00 root data:Selection - └─Selection 0.00 cop[tikv] lt(util__ranger.t.a, 1) +└─TableReader 1.00 root data:Selection + └─Selection 1.00 cop[tikv] lt(util__ranger.t.a, 1) └─TableFullScan 3.00 cop[tikv] table:t, partition:p1 keep order:false select * from t where a < 1; a b @@ -227,9 +227,9 @@ select * from t where a < -1; a b explain format='brief' select * from t where a > 0; id estRows task access object operator info -PartitionUnion 3.00 root -├─TableReader 0.00 root data:Selection -│ └─Selection 0.00 cop[tikv] gt(util__ranger.t.a, 0) +PartitionUnion 4.00 root +├─TableReader 1.00 root data:Selection +│ └─Selection 1.00 cop[tikv] gt(util__ranger.t.a, 0) │ └─TableFullScan 1.00 cop[tikv] table:t, partition:p0 keep order:false └─TableReader 3.00 root data:Selection └─Selection 3.00 cop[tikv] gt(util__ranger.t.a, 0) @@ -256,12 +256,12 @@ a b  3 explain format='brief' select * from t where a > 3; id estRows task access object operator info -PartitionUnion 0.00 root -├─TableReader 0.00 root data:Selection -│ └─Selection 0.00 cop[tikv] gt(util__ranger.t.a, 3) +PartitionUnion 2.00 root +├─TableReader 1.00 root data:Selection +│ └─Selection 1.00 cop[tikv] gt(util__ranger.t.a, 3) │ └─TableFullScan 1.00 cop[tikv] table:t, partition:p0 keep order:false -└─TableReader 0.00 root data:Selection - └─Selection 0.00 cop[tikv] gt(util__ranger.t.a, 3) +└─TableReader 1.00 root data:Selection + └─Selection 1.00 cop[tikv] gt(util__ranger.t.a, 3) └─TableFullScan 3.00 cop[tikv] table:t, partition:p1 keep order:false select * from t where a > 3; a b diff --git a/tests/integrationtest/t/planner/cardinality/selectivity.test b/tests/integrationtest/t/planner/cardinality/selectivity.test index 37dff39b9ed26..b865738ef56bb 100644 --- a/tests/integrationtest/t/planner/cardinality/selectivity.test +++ b/tests/integrationtest/t/planner/cardinality/selectivity.test @@ -647,6 +647,9 @@ insert into t values ('tw', 0); insert into t values ('tw', 0); analyze table t all columns; explain select * from t where a = 'tw' and b < 0; +set @@tidb_opt_fix_control = '47400:on'; +explain select * from t where a = 'tw' and b < 0; +set @@tidb_opt_fix_control = '47400:off'; # TestSelectCombinedLowBound drop table if exists t;