diff --git a/pkg/executor/infoschema_reader_test.go b/pkg/executor/infoschema_reader_test.go index c499939133af0..2af48afda10b0 100644 --- a/pkg/executor/infoschema_reader_test.go +++ b/pkg/executor/infoschema_reader_test.go @@ -982,10 +982,10 @@ func TestInfoSchemaDDLJobs(t *testing.T) { )) // Test explain output, since the output may change in future. - tk.MustQuery(`EXPLAIN SELECT * FROM information_schema.ddl_jobs where db_name = "test2" limit 10;`).Check(testkit.Rows( - `Limit_10 10.00 root offset:0, count:10`, - `└─Selection_11 10.00 root eq(Column#2, "test2")`, - ` └─MemTableScan_12 10000.00 root table:DDL_JOBS db_name:["test2"]`, + tk.MustQuery(`EXPLAIN FORMAT='brief' SELECT * FROM information_schema.ddl_jobs where db_name = "test2" limit 10;`).Check(testkit.Rows( + `Limit 10.00 root offset:0, count:10`, + `└─Selection 10.00 root eq(Column#2, "test2")`, + ` └─MemTableScan 10000.00 root table:DDL_JOBS db_name:["test2"]`, )) } diff --git a/pkg/planner/core/casetest/vectorsearch/testdata/ann_index_suite_in.json b/pkg/planner/core/casetest/vectorsearch/testdata/ann_index_suite_in.json index b682d966a5d9a..1f46b52b2ec2d 100644 --- a/pkg/planner/core/casetest/vectorsearch/testdata/ann_index_suite_in.json +++ b/pkg/planner/core/casetest/vectorsearch/testdata/ann_index_suite_in.json @@ -48,65 +48,59 @@ { "name": "TestVectorSearchWithPKAuto", "cases": [ - "explain select id from t1", - - "explain select id from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", - "explain select id from t1 order by vec_cosine_distance(vec, '[1,1,1]')", - "explain select * from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", - "explain select id, a, b from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", - "explain select a, id, b from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", - - "explain select id, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", - "explain select id, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d", - "explain select *, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", - "explain select id, vec_cosine_distance(vec, '[1,1,1]') as d, a, b from t1 order by d limit 10", - "explain select id, a, b, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d limit 10" + "explain format = 'brief' select id from t1", + "explain format = 'brief' select id from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", + "explain format = 'brief' select id from t1 order by vec_cosine_distance(vec, '[1,1,1]')", + "explain format = 'brief' select * from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", + "explain format = 'brief' select id, a, b from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", + "explain format = 'brief' select a, id, b from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", + "explain format = 'brief' select id, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", + "explain format = 'brief' select id, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d", + "explain format = 'brief' select *, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", + "explain format = 'brief' select id, vec_cosine_distance(vec, '[1,1,1]') as d, a, b from t1 order by d limit 10", + "explain format = 'brief' select id, a, b, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d limit 10" ] }, { "name": "TestVectorSearchWithPKForceTiKV", "cases": [ - "explain select id from t1", - - "explain select id from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", - "explain select id from t1 order by vec_cosine_distance(vec, '[1,1,1]')", - "explain select * from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", - "explain select id, a, b from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", - "explain select a, id, b from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", - - "explain select id, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", - "explain select id, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d", - "explain select *, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", - "explain select id, vec_cosine_distance(vec, '[1,1,1]') as d, a, b from t1 order by d limit 10", - "explain select id, a, b, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d limit 10" + "explain format = 'brief' select id from t1", + "explain format = 'brief' select id from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", + "explain format = 'brief' select id from t1 order by vec_cosine_distance(vec, '[1,1,1]')", + "explain format = 'brief' select * from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", + "explain format = 'brief' select id, a, b from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", + "explain format = 'brief' select a, id, b from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", + "explain format = 'brief' select id, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", + "explain format = 'brief' select id, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d", + "explain format = 'brief' select *, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", + "explain format = 'brief' select id, vec_cosine_distance(vec, '[1,1,1]') as d, a, b from t1 order by d limit 10", + "explain format = 'brief' select id, a, b, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d limit 10" ] }, { "name": "TestVectorSearchHeavyFunction", "cases": [ - "explain select id from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", - "explain select id from t1 order by vec_l1_distance(vec, '[1,1,1]') limit 10", - "explain select id from t1 order by vec_l2_distance(vec, '[1,1,1]') limit 10", - "explain select id from t1 order by vec_negative_inner_product(vec, '[1,1,1]') limit 10", - "explain select id from t1 order by vec_dims(vec) limit 10", - "explain select id from t1 order by vec_l2_norm(vec) limit 10", - "explain select id from t1 order by MOD(a, 3) limit 10", - - "explain select id, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", - "explain select id, vec_l1_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", - "explain select id, vec_l2_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", - "explain select id, vec_negative_inner_product(vec, '[1,1,1]') as d from t1 order by d limit 10", - "explain select id, vec_dims(vec) as d from t1 order by d limit 10", - "explain select id, vec_l2_norm(vec) as d from t1 order by d limit 10", - "explain select id, MOD(a, 3) as d from t1 order by d limit 10", - - "explain select * from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", - "explain select * from t1 order by vec_l1_distance(vec, '[1,1,1]') limit 10", - "explain select * from t1 order by vec_l2_distance(vec, '[1,1,1]') limit 10", - "explain select * from t1 order by vec_negative_inner_product(vec, '[1,1,1]') limit 10", - "explain select * from t1 order by vec_dims(vec) limit 10", - "explain select * from t1 order by vec_l2_norm(vec) limit 10", - "explain select * from t1 order by MOD(a, 3) limit 10" + "explain format = 'brief' select id from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", + "explain format = 'brief' select id from t1 order by vec_l1_distance(vec, '[1,1,1]') limit 10", + "explain format = 'brief' select id from t1 order by vec_l2_distance(vec, '[1,1,1]') limit 10", + "explain format = 'brief' select id from t1 order by vec_negative_inner_product(vec, '[1,1,1]') limit 10", + "explain format = 'brief' select id from t1 order by vec_dims(vec) limit 10", + "explain format = 'brief' select id from t1 order by vec_l2_norm(vec) limit 10", + "explain format = 'brief' select id from t1 order by MOD(a, 3) limit 10", + "explain format = 'brief' select id, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", + "explain format = 'brief' select id, vec_l1_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", + "explain format = 'brief' select id, vec_l2_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", + "explain format = 'brief' select id, vec_negative_inner_product(vec, '[1,1,1]') as d from t1 order by d limit 10", + "explain format = 'brief' select id, vec_dims(vec) as d from t1 order by d limit 10", + "explain format = 'brief' select id, vec_l2_norm(vec) as d from t1 order by d limit 10", + "explain format = 'brief' select id, MOD(a, 3) as d from t1 order by d limit 10", + "explain format = 'brief' select * from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", + "explain format = 'brief' select * from t1 order by vec_l1_distance(vec, '[1,1,1]') limit 10", + "explain format = 'brief' select * from t1 order by vec_l2_distance(vec, '[1,1,1]') limit 10", + "explain format = 'brief' select * from t1 order by vec_negative_inner_product(vec, '[1,1,1]') limit 10", + "explain format = 'brief' select * from t1 order by vec_dims(vec) limit 10", + "explain format = 'brief' select * from t1 order by vec_l2_norm(vec) limit 10", + "explain format = 'brief' select * from t1 order by MOD(a, 3) limit 10" ] } ] diff --git a/pkg/planner/core/casetest/vectorsearch/testdata/ann_index_suite_out.json b/pkg/planner/core/casetest/vectorsearch/testdata/ann_index_suite_out.json index 95023baaff8fe..b003cd040331a 100644 --- a/pkg/planner/core/casetest/vectorsearch/testdata/ann_index_suite_out.json +++ b/pkg/planner/core/casetest/vectorsearch/testdata/ann_index_suite_out.json @@ -436,133 +436,133 @@ "Name": "TestVectorSearchWithPKAuto", "Cases": [ { - "SQL": "explain select id from t1", + "SQL": "explain format = 'brief' select id from t1", "Plan": [ - "TableReader_14 6000.00 root MppVersion: 3, data:ExchangeSender_13", - "└─ExchangeSender_13 6000.00 mpp[tiflash] ExchangeType: PassThrough", - " └─TableFullScan_11 6000.00 mpp[tiflash] table:t1 keep order:false" + "TableReader 6000.00 root MppVersion: 3, data:ExchangeSender", + "└─ExchangeSender 6000.00 mpp[tiflash] ExchangeType: PassThrough", + " └─TableFullScan 6000.00 mpp[tiflash] table:t1 keep order:false" ], "Warn": null }, { - "SQL": "explain select id from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", + "SQL": "explain format = 'brief' select id from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", "Plan": [ - "TopN_11 10.00 root Column#11, offset:0, count:10", - "└─TableReader_29 10.00 root MppVersion: 3, data:ExchangeSender_28", - " └─ExchangeSender_28 10.00 mpp[tiflash] ExchangeType: PassThrough", - " └─TopN_27 10.00 mpp[tiflash] Column#11, offset:0, count:10", - " └─TableFullScan_25 10.00 mpp[tiflash] table:t1, index:idx_embedding(vec) keep order:false, annIndex:COSINE(vec..[1,1,1], limit:10)->Column#11" + "TopN 10.00 root Column#11, offset:0, count:10", + "└─TableReader 10.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 10.00 mpp[tiflash] ExchangeType: PassThrough", + " └─TopN 10.00 mpp[tiflash] Column#11, offset:0, count:10", + " └─TableFullScan 10.00 mpp[tiflash] table:t1, index:idx_embedding(vec) keep order:false, annIndex:COSINE(vec..[1,1,1], limit:10)->Column#11" ], "Warn": null }, { - "SQL": "explain select id from t1 order by vec_cosine_distance(vec, '[1,1,1]')", + "SQL": "explain format = 'brief' select id from t1 order by vec_cosine_distance(vec, '[1,1,1]')", "Plan": [ - "Projection_5 6000.00 root test.t1.id", - "└─Projection_14 6000.00 root test.t1.id, test.t1.vec", - " └─Sort_7 6000.00 root Column#8", - " └─Projection_15 6000.00 root test.t1.id, test.t1.vec, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#8", - " └─TableReader_12 6000.00 root MppVersion: 3, data:ExchangeSender_11", - " └─ExchangeSender_11 6000.00 mpp[tiflash] ExchangeType: PassThrough", - " └─TableFullScan_10 6000.00 mpp[tiflash] table:t1 keep order:false" + "Projection 6000.00 root test.t1.id", + "└─Projection 6000.00 root test.t1.id, test.t1.vec", + " └─Sort 6000.00 root Column#8", + " └─Projection 6000.00 root test.t1.id, test.t1.vec, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#8", + " └─TableReader 6000.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 6000.00 mpp[tiflash] ExchangeType: PassThrough", + " └─TableFullScan 6000.00 mpp[tiflash] table:t1 keep order:false" ], "Warn": null }, { - "SQL": "explain select * from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", + "SQL": "explain format = 'brief' select * from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", "Plan": [ - "TopN_10 10.00 root Column#9, offset:0, count:10", - "└─TableReader_28 10.00 root MppVersion: 3, data:ExchangeSender_27", - " └─ExchangeSender_27 10.00 mpp[tiflash] ExchangeType: PassThrough", - " └─TopN_26 10.00 mpp[tiflash] Column#9, offset:0, count:10", - " └─Projection_25 10.00 mpp[tiflash] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#9", - " └─TableFullScan_24 10.00 mpp[tiflash] table:t1, index:idx_embedding(vec) keep order:false, annIndex:COSINE(vec..[1,1,1], limit:10)" + "TopN 10.00 root Column#9, offset:0, count:10", + "└─TableReader 10.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 10.00 mpp[tiflash] ExchangeType: PassThrough", + " └─TopN 10.00 mpp[tiflash] Column#9, offset:0, count:10", + " └─Projection 10.00 mpp[tiflash] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#9", + " └─TableFullScan 10.00 mpp[tiflash] table:t1, index:idx_embedding(vec) keep order:false, annIndex:COSINE(vec..[1,1,1], limit:10)" ], "Warn": null }, { - "SQL": "explain select id, a, b from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", + "SQL": "explain format = 'brief' select id, a, b from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", "Plan": [ - "TopN_11 10.00 root Column#13, offset:0, count:10", - "└─TableReader_29 10.00 root MppVersion: 3, data:ExchangeSender_28", - " └─ExchangeSender_28 10.00 mpp[tiflash] ExchangeType: PassThrough", - " └─TopN_27 10.00 mpp[tiflash] Column#13, offset:0, count:10", - " └─TableFullScan_25 10.00 mpp[tiflash] table:t1, index:idx_embedding(vec) keep order:false, annIndex:COSINE(vec..[1,1,1], limit:10)->Column#13" + "TopN 10.00 root Column#13, offset:0, count:10", + "└─TableReader 10.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 10.00 mpp[tiflash] ExchangeType: PassThrough", + " └─TopN 10.00 mpp[tiflash] Column#13, offset:0, count:10", + " └─TableFullScan 10.00 mpp[tiflash] table:t1, index:idx_embedding(vec) keep order:false, annIndex:COSINE(vec..[1,1,1], limit:10)->Column#13" ], "Warn": null }, { - "SQL": "explain select a, id, b from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", + "SQL": "explain format = 'brief' select a, id, b from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", "Plan": [ - "Projection_7 10.00 root test.t1.a, test.t1.id, test.t1.b", - "└─TopN_11 10.00 root Column#13, offset:0, count:10", - " └─TableReader_29 10.00 root MppVersion: 3, data:ExchangeSender_28", - " └─ExchangeSender_28 10.00 mpp[tiflash] ExchangeType: PassThrough", - " └─TopN_27 10.00 mpp[tiflash] Column#13, offset:0, count:10", - " └─TableFullScan_25 10.00 mpp[tiflash] table:t1, index:idx_embedding(vec) keep order:false, annIndex:COSINE(vec..[1,1,1], limit:10)->Column#13" + "Projection 10.00 root test.t1.a, test.t1.id, test.t1.b", + "└─TopN 10.00 root Column#13, offset:0, count:10", + " └─TableReader 10.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 10.00 mpp[tiflash] ExchangeType: PassThrough", + " └─TopN 10.00 mpp[tiflash] Column#13, offset:0, count:10", + " └─TableFullScan 10.00 mpp[tiflash] table:t1, index:idx_embedding(vec) keep order:false, annIndex:COSINE(vec..[1,1,1], limit:10)->Column#13" ], "Warn": null }, { - "SQL": "explain select id, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", + "SQL": "explain format = 'brief' select id, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", "Plan": [ - "Projection_6 10.00 root test.t1.id, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#7", - "└─TopN_10 10.00 root Column#10, offset:0, count:10", - " └─TableReader_28 10.00 root MppVersion: 3, data:ExchangeSender_27", - " └─ExchangeSender_27 10.00 mpp[tiflash] ExchangeType: PassThrough", - " └─TopN_26 10.00 mpp[tiflash] Column#10, offset:0, count:10", - " └─Projection_25 10.00 mpp[tiflash] test.t1.id, test.t1.vec, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#10", - " └─TableFullScan_24 10.00 mpp[tiflash] table:t1, index:idx_embedding(vec) keep order:false, annIndex:COSINE(vec..[1,1,1], limit:10)" + "Projection 10.00 root test.t1.id, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#7", + "└─TopN 10.00 root Column#10, offset:0, count:10", + " └─TableReader 10.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 10.00 mpp[tiflash] ExchangeType: PassThrough", + " └─TopN 10.00 mpp[tiflash] Column#10, offset:0, count:10", + " └─Projection 10.00 mpp[tiflash] test.t1.id, test.t1.vec, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#10", + " └─TableFullScan 10.00 mpp[tiflash] table:t1, index:idx_embedding(vec) keep order:false, annIndex:COSINE(vec..[1,1,1], limit:10)" ], "Warn": null }, { - "SQL": "explain select id, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d", + "SQL": "explain format = 'brief' select id, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d", "Plan": [ - "Sort_4 6000.00 root Column#7", - "└─TableReader_17 6000.00 root MppVersion: 3, data:ExchangeSender_16", - " └─ExchangeSender_16 6000.00 mpp[tiflash] ExchangeType: PassThrough", - " └─Projection_7 6000.00 mpp[tiflash] test.t1.id, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#7", - " └─TableFullScan_14 6000.00 mpp[tiflash] table:t1 keep order:false" + "Sort 6000.00 root Column#7", + "└─TableReader 6000.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 6000.00 mpp[tiflash] ExchangeType: PassThrough", + " └─Projection 6000.00 mpp[tiflash] test.t1.id, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#7", + " └─TableFullScan 6000.00 mpp[tiflash] table:t1 keep order:false" ], "Warn": null }, { - "SQL": "explain select *, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", + "SQL": "explain format = 'brief' select *, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", "Plan": [ - "Projection_6 10.00 root test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#7", - "└─TopN_10 10.00 root Column#10, offset:0, count:10", - " └─TableReader_28 10.00 root MppVersion: 3, data:ExchangeSender_27", - " └─ExchangeSender_27 10.00 mpp[tiflash] ExchangeType: PassThrough", - " └─TopN_26 10.00 mpp[tiflash] Column#10, offset:0, count:10", - " └─Projection_25 10.00 mpp[tiflash] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#10", - " └─TableFullScan_24 10.00 mpp[tiflash] table:t1, index:idx_embedding(vec) keep order:false, annIndex:COSINE(vec..[1,1,1], limit:10)" + "Projection 10.00 root test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#7", + "└─TopN 10.00 root Column#10, offset:0, count:10", + " └─TableReader 10.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 10.00 mpp[tiflash] ExchangeType: PassThrough", + " └─TopN 10.00 mpp[tiflash] Column#10, offset:0, count:10", + " └─Projection 10.00 mpp[tiflash] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#10", + " └─TableFullScan 10.00 mpp[tiflash] table:t1, index:idx_embedding(vec) keep order:false, annIndex:COSINE(vec..[1,1,1], limit:10)" ], "Warn": null }, { - "SQL": "explain select id, vec_cosine_distance(vec, '[1,1,1]') as d, a, b from t1 order by d limit 10", + "SQL": "explain format = 'brief' select id, vec_cosine_distance(vec, '[1,1,1]') as d, a, b from t1 order by d limit 10", "Plan": [ - "Projection_6 10.00 root test.t1.id, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#7, test.t1.a, test.t1.b", - "└─TopN_10 10.00 root Column#10, offset:0, count:10", - " └─TableReader_28 10.00 root MppVersion: 3, data:ExchangeSender_27", - " └─ExchangeSender_27 10.00 mpp[tiflash] ExchangeType: PassThrough", - " └─TopN_26 10.00 mpp[tiflash] Column#10, offset:0, count:10", - " └─Projection_25 10.00 mpp[tiflash] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#10", - " └─TableFullScan_24 10.00 mpp[tiflash] table:t1, index:idx_embedding(vec) keep order:false, annIndex:COSINE(vec..[1,1,1], limit:10)" + "Projection 10.00 root test.t1.id, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#7, test.t1.a, test.t1.b", + "└─TopN 10.00 root Column#10, offset:0, count:10", + " └─TableReader 10.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 10.00 mpp[tiflash] ExchangeType: PassThrough", + " └─TopN 10.00 mpp[tiflash] Column#10, offset:0, count:10", + " └─Projection 10.00 mpp[tiflash] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#10", + " └─TableFullScan 10.00 mpp[tiflash] table:t1, index:idx_embedding(vec) keep order:false, annIndex:COSINE(vec..[1,1,1], limit:10)" ], "Warn": null }, { - "SQL": "explain select id, a, b, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", + "SQL": "explain format = 'brief' select id, a, b, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", "Plan": [ - "Projection_6 10.00 root test.t1.id, test.t1.a, test.t1.b, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#7", - "└─TopN_10 10.00 root Column#10, offset:0, count:10", - " └─TableReader_28 10.00 root MppVersion: 3, data:ExchangeSender_27", - " └─ExchangeSender_27 10.00 mpp[tiflash] ExchangeType: PassThrough", - " └─TopN_26 10.00 mpp[tiflash] Column#10, offset:0, count:10", - " └─Projection_25 10.00 mpp[tiflash] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#10", - " └─TableFullScan_24 10.00 mpp[tiflash] table:t1, index:idx_embedding(vec) keep order:false, annIndex:COSINE(vec..[1,1,1], limit:10)" + "Projection 10.00 root test.t1.id, test.t1.a, test.t1.b, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#7", + "└─TopN 10.00 root Column#10, offset:0, count:10", + " └─TableReader 10.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 10.00 mpp[tiflash] ExchangeType: PassThrough", + " └─TopN 10.00 mpp[tiflash] Column#10, offset:0, count:10", + " └─Projection 10.00 mpp[tiflash] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#10", + " └─TableFullScan 10.00 mpp[tiflash] table:t1, index:idx_embedding(vec) keep order:false, annIndex:COSINE(vec..[1,1,1], limit:10)" ], "Warn": null } @@ -572,125 +572,125 @@ "Name": "TestVectorSearchWithPKForceTiKV", "Cases": [ { - "SQL": "explain select id from t1", + "SQL": "explain format = 'brief' select id from t1", "Plan": [ - "TableReader_5 6000.00 root data:TableFullScan_4", - "└─TableFullScan_4 6000.00 cop[tikv] table:t1 keep order:false" + "TableReader 6000.00 root data:TableFullScan", + "└─TableFullScan 6000.00 cop[tikv] table:t1 keep order:false" ], "Warn": null }, { - "SQL": "explain select id from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", + "SQL": "explain format = 'brief' select id from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", "Plan": [ - "TopN_8 10.00 root Column#8, offset:0, count:10", - "└─TableReader_15 10.00 root data:TopN_14", - " └─TopN_14 10.00 cop[tikv] Column#8, offset:0, count:10", - " └─Projection_13 10.00 cop[tikv] test.t1.id, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#8", - " └─TableFullScan_12 6000.00 cop[tikv] table:t1 keep order:false" + "TopN 10.00 root Column#8, offset:0, count:10", + "└─TableReader 10.00 root data:TopN", + " └─TopN 10.00 cop[tikv] Column#8, offset:0, count:10", + " └─Projection 10.00 cop[tikv] test.t1.id, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#8", + " └─TableFullScan 6000.00 cop[tikv] table:t1 keep order:false" ], "Warn": null }, { - "SQL": "explain select id from t1 order by vec_cosine_distance(vec, '[1,1,1]')", + "SQL": "explain format = 'brief' select id from t1 order by vec_cosine_distance(vec, '[1,1,1]')", "Plan": [ - "Projection_5 6000.00 root test.t1.id", - "└─Projection_9 6000.00 root test.t1.id, test.t1.vec", - " └─Sort_6 6000.00 root Column#8", - " └─Projection_10 6000.00 root test.t1.id, test.t1.vec, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#8", - " └─TableReader_8 6000.00 root data:TableFullScan_7", - " └─TableFullScan_7 6000.00 cop[tikv] table:t1 keep order:false" + "Projection 6000.00 root test.t1.id", + "└─Projection 6000.00 root test.t1.id, test.t1.vec", + " └─Sort 6000.00 root Column#8", + " └─Projection 6000.00 root test.t1.id, test.t1.vec, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#8", + " └─TableReader 6000.00 root data:TableFullScan", + " └─TableFullScan 6000.00 cop[tikv] table:t1 keep order:false" ], "Warn": null }, { - "SQL": "explain select * from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", + "SQL": "explain format = 'brief' select * from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", "Plan": [ - "TopN_7 10.00 root Column#7, offset:0, count:10", - "└─TableReader_14 10.00 root data:TopN_13", - " └─TopN_13 10.00 cop[tikv] Column#7, offset:0, count:10", - " └─Projection_12 10.00 cop[tikv] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#7", - " └─TableFullScan_11 6000.00 cop[tikv] table:t1 keep order:false" + "TopN 10.00 root Column#7, offset:0, count:10", + "└─TableReader 10.00 root data:TopN", + " └─TopN 10.00 cop[tikv] Column#7, offset:0, count:10", + " └─Projection 10.00 cop[tikv] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#7", + " └─TableFullScan 6000.00 cop[tikv] table:t1 keep order:false" ], "Warn": null }, { - "SQL": "explain select id, a, b from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", + "SQL": "explain format = 'brief' select id, a, b from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", "Plan": [ - "TopN_8 10.00 root Column#10, offset:0, count:10", - "└─TableReader_15 10.00 root data:TopN_14", - " └─TopN_14 10.00 cop[tikv] Column#10, offset:0, count:10", - " └─Projection_13 10.00 cop[tikv] test.t1.id, test.t1.a, test.t1.b, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#10", - " └─TableFullScan_12 6000.00 cop[tikv] table:t1 keep order:false" + "TopN 10.00 root Column#10, offset:0, count:10", + "└─TableReader 10.00 root data:TopN", + " └─TopN 10.00 cop[tikv] Column#10, offset:0, count:10", + " └─Projection 10.00 cop[tikv] test.t1.id, test.t1.a, test.t1.b, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#10", + " └─TableFullScan 6000.00 cop[tikv] table:t1 keep order:false" ], "Warn": null }, { - "SQL": "explain select a, id, b from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", + "SQL": "explain format = 'brief' select a, id, b from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", "Plan": [ - "Projection_7 10.00 root test.t1.a, test.t1.id, test.t1.b", - "└─TopN_8 10.00 root Column#10, offset:0, count:10", - " └─TableReader_15 10.00 root data:TopN_14", - " └─TopN_14 10.00 cop[tikv] Column#10, offset:0, count:10", - " └─Projection_13 10.00 cop[tikv] test.t1.id, test.t1.a, test.t1.b, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#10", - " └─TableFullScan_12 6000.00 cop[tikv] table:t1 keep order:false" + "Projection 10.00 root test.t1.a, test.t1.id, test.t1.b", + "└─TopN 10.00 root Column#10, offset:0, count:10", + " └─TableReader 10.00 root data:TopN", + " └─TopN 10.00 cop[tikv] Column#10, offset:0, count:10", + " └─Projection 10.00 cop[tikv] test.t1.id, test.t1.a, test.t1.b, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#10", + " └─TableFullScan 6000.00 cop[tikv] table:t1 keep order:false" ], "Warn": null }, { - "SQL": "explain select id, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", + "SQL": "explain format = 'brief' select id, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", "Plan": [ - "Projection_6 10.00 root test.t1.id, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#7", - "└─TopN_7 10.00 root Column#8, offset:0, count:10", - " └─TableReader_14 10.00 root data:TopN_13", - " └─TopN_13 10.00 cop[tikv] Column#8, offset:0, count:10", - " └─Projection_12 10.00 cop[tikv] test.t1.id, test.t1.vec, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#8", - " └─TableFullScan_11 6000.00 cop[tikv] table:t1 keep order:false" + "Projection 10.00 root test.t1.id, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#7", + "└─TopN 10.00 root Column#8, offset:0, count:10", + " └─TableReader 10.00 root data:TopN", + " └─TopN 10.00 cop[tikv] Column#8, offset:0, count:10", + " └─Projection 10.00 cop[tikv] test.t1.id, test.t1.vec, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#8", + " └─TableFullScan 6000.00 cop[tikv] table:t1 keep order:false" ], "Warn": null }, { - "SQL": "explain select id, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d", + "SQL": "explain format = 'brief' select id, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d", "Plan": [ - "Sort_4 6000.00 root Column#7", - "└─Projection_6 6000.00 root test.t1.id, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#7", - " └─TableReader_8 6000.00 root data:TableFullScan_7", - " └─TableFullScan_7 6000.00 cop[tikv] table:t1 keep order:false" + "Sort 6000.00 root Column#7", + "└─Projection 6000.00 root test.t1.id, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#7", + " └─TableReader 6000.00 root data:TableFullScan", + " └─TableFullScan 6000.00 cop[tikv] table:t1 keep order:false" ], "Warn": null }, { - "SQL": "explain select *, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", + "SQL": "explain format = 'brief' select *, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", "Plan": [ - "Projection_6 10.00 root test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#7", - "└─TopN_7 10.00 root Column#8, offset:0, count:10", - " └─TableReader_14 10.00 root data:TopN_13", - " └─TopN_13 10.00 cop[tikv] Column#8, offset:0, count:10", - " └─Projection_12 10.00 cop[tikv] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#8", - " └─TableFullScan_11 6000.00 cop[tikv] table:t1 keep order:false" + "Projection 10.00 root test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#7", + "└─TopN 10.00 root Column#8, offset:0, count:10", + " └─TableReader 10.00 root data:TopN", + " └─TopN 10.00 cop[tikv] Column#8, offset:0, count:10", + " └─Projection 10.00 cop[tikv] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#8", + " └─TableFullScan 6000.00 cop[tikv] table:t1 keep order:false" ], "Warn": null }, { - "SQL": "explain select id, vec_cosine_distance(vec, '[1,1,1]') as d, a, b from t1 order by d limit 10", + "SQL": "explain format = 'brief' select id, vec_cosine_distance(vec, '[1,1,1]') as d, a, b from t1 order by d limit 10", "Plan": [ - "Projection_6 10.00 root test.t1.id, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#7, test.t1.a, test.t1.b", - "└─TopN_7 10.00 root Column#8, offset:0, count:10", - " └─TableReader_14 10.00 root data:TopN_13", - " └─TopN_13 10.00 cop[tikv] Column#8, offset:0, count:10", - " └─Projection_12 10.00 cop[tikv] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#8", - " └─TableFullScan_11 6000.00 cop[tikv] table:t1 keep order:false" + "Projection 10.00 root test.t1.id, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#7, test.t1.a, test.t1.b", + "└─TopN 10.00 root Column#8, offset:0, count:10", + " └─TableReader 10.00 root data:TopN", + " └─TopN 10.00 cop[tikv] Column#8, offset:0, count:10", + " └─Projection 10.00 cop[tikv] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#8", + " └─TableFullScan 6000.00 cop[tikv] table:t1 keep order:false" ], "Warn": null }, { - "SQL": "explain select id, a, b, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", + "SQL": "explain format = 'brief' select id, a, b, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", "Plan": [ - "Projection_6 10.00 root test.t1.id, test.t1.a, test.t1.b, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#7", - "└─TopN_7 10.00 root Column#8, offset:0, count:10", - " └─TableReader_14 10.00 root data:TopN_13", - " └─TopN_13 10.00 cop[tikv] Column#8, offset:0, count:10", - " └─Projection_12 10.00 cop[tikv] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#8", - " └─TableFullScan_11 6000.00 cop[tikv] table:t1 keep order:false" + "Projection 10.00 root test.t1.id, test.t1.a, test.t1.b, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#7", + "└─TopN 10.00 root Column#8, offset:0, count:10", + " └─TableReader 10.00 root data:TopN", + " └─TopN 10.00 cop[tikv] Column#8, offset:0, count:10", + " └─Projection 10.00 cop[tikv] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#8", + " └─TableFullScan 6000.00 cop[tikv] table:t1 keep order:false" ], "Warn": null } @@ -700,272 +700,272 @@ "Name": "TestVectorSearchHeavyFunction", "Cases": [ { - "SQL": "explain select id from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", + "SQL": "explain format = 'brief' select id from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", "Plan": [ - "TopN_11 10.00 root Column#11, offset:0, count:10", - "└─TableReader_29 10.00 root MppVersion: 3, data:ExchangeSender_28", - " └─ExchangeSender_28 10.00 mpp[tiflash] ExchangeType: PassThrough", - " └─TopN_27 10.00 mpp[tiflash] Column#11, offset:0, count:10", - " └─TableFullScan_25 10.00 mpp[tiflash] table:t1, index:idx_embedding(vec) keep order:false, annIndex:COSINE(vec..[1,1,1], limit:10)->Column#11" + "TopN 10.00 root Column#11, offset:0, count:10", + "└─TableReader 10.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 10.00 mpp[tiflash] ExchangeType: PassThrough", + " └─TopN 10.00 mpp[tiflash] Column#11, offset:0, count:10", + " └─TableFullScan 10.00 mpp[tiflash] table:t1, index:idx_embedding(vec) keep order:false, annIndex:COSINE(vec..[1,1,1], limit:10)->Column#11" ], "Warn": null }, { - "SQL": "explain select id from t1 order by vec_l1_distance(vec, '[1,1,1]') limit 10", + "SQL": "explain format = 'brief' select id from t1 order by vec_l1_distance(vec, '[1,1,1]') limit 10", "Plan": [ - "TopN_10 10.00 root Column#9, offset:0, count:10", - "└─TableReader_23 10.00 root MppVersion: 3, data:ExchangeSender_22", - " └─ExchangeSender_22 10.00 mpp[tiflash] ExchangeType: PassThrough", - " └─TopN_21 10.00 mpp[tiflash] Column#9, offset:0, count:10", - " └─Projection_20 10.00 mpp[tiflash] test.t1.id, vec_l1_distance(test.t1.vec, [1,1,1])->Column#9", - " └─TableFullScan_18 6000.00 mpp[tiflash] table:t1 keep order:false" + "TopN 10.00 root Column#9, offset:0, count:10", + "└─TableReader 10.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 10.00 mpp[tiflash] ExchangeType: PassThrough", + " └─TopN 10.00 mpp[tiflash] Column#9, offset:0, count:10", + " └─Projection 10.00 mpp[tiflash] test.t1.id, vec_l1_distance(test.t1.vec, [1,1,1])->Column#9", + " └─TableFullScan 6000.00 mpp[tiflash] table:t1 keep order:false" ], "Warn": null }, { - "SQL": "explain select id from t1 order by vec_l2_distance(vec, '[1,1,1]') limit 10", + "SQL": "explain format = 'brief' select id from t1 order by vec_l2_distance(vec, '[1,1,1]') limit 10", "Plan": [ - "TopN_10 10.00 root Column#9, offset:0, count:10", - "└─TableReader_23 10.00 root MppVersion: 3, data:ExchangeSender_22", - " └─ExchangeSender_22 10.00 mpp[tiflash] ExchangeType: PassThrough", - " └─TopN_21 10.00 mpp[tiflash] Column#9, offset:0, count:10", - " └─Projection_20 10.00 mpp[tiflash] test.t1.id, vec_l2_distance(test.t1.vec, [1,1,1])->Column#9", - " └─TableFullScan_18 6000.00 mpp[tiflash] table:t1 keep order:false" + "TopN 10.00 root Column#9, offset:0, count:10", + "└─TableReader 10.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 10.00 mpp[tiflash] ExchangeType: PassThrough", + " └─TopN 10.00 mpp[tiflash] Column#9, offset:0, count:10", + " └─Projection 10.00 mpp[tiflash] test.t1.id, vec_l2_distance(test.t1.vec, [1,1,1])->Column#9", + " └─TableFullScan 6000.00 mpp[tiflash] table:t1 keep order:false" ], "Warn": null }, { - "SQL": "explain select id from t1 order by vec_negative_inner_product(vec, '[1,1,1]') limit 10", + "SQL": "explain format = 'brief' select id from t1 order by vec_negative_inner_product(vec, '[1,1,1]') limit 10", "Plan": [ - "TopN_10 10.00 root Column#9, offset:0, count:10", - "└─TableReader_23 10.00 root MppVersion: 3, data:ExchangeSender_22", - " └─ExchangeSender_22 10.00 mpp[tiflash] ExchangeType: PassThrough", - " └─TopN_21 10.00 mpp[tiflash] Column#9, offset:0, count:10", - " └─Projection_20 10.00 mpp[tiflash] test.t1.id, vec_negative_inner_product(test.t1.vec, [1,1,1])->Column#9", - " └─TableFullScan_18 6000.00 mpp[tiflash] table:t1 keep order:false" + "TopN 10.00 root Column#9, offset:0, count:10", + "└─TableReader 10.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 10.00 mpp[tiflash] ExchangeType: PassThrough", + " └─TopN 10.00 mpp[tiflash] Column#9, offset:0, count:10", + " └─Projection 10.00 mpp[tiflash] test.t1.id, vec_negative_inner_product(test.t1.vec, [1,1,1])->Column#9", + " └─TableFullScan 6000.00 mpp[tiflash] table:t1 keep order:false" ], "Warn": null }, { - "SQL": "explain select id from t1 order by vec_dims(vec) limit 10", + "SQL": "explain format = 'brief' select id from t1 order by vec_dims(vec) limit 10", "Plan": [ - "TopN_10 10.00 root Column#9, offset:0, count:10", - "└─TableReader_22 10.00 root MppVersion: 3, data:ExchangeSender_21", - " └─ExchangeSender_21 10.00 mpp[tiflash] ExchangeType: PassThrough", - " └─TopN_20 10.00 mpp[tiflash] Column#9, offset:0, count:10", - " └─Projection_19 10.00 mpp[tiflash] test.t1.id, vec_dims(test.t1.vec)->Column#9", - " └─TableFullScan_17 6000.00 mpp[tiflash] table:t1 keep order:false" + "TopN 10.00 root Column#9, offset:0, count:10", + "└─TableReader 10.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 10.00 mpp[tiflash] ExchangeType: PassThrough", + " └─TopN 10.00 mpp[tiflash] Column#9, offset:0, count:10", + " └─Projection 10.00 mpp[tiflash] test.t1.id, vec_dims(test.t1.vec)->Column#9", + " └─TableFullScan 6000.00 mpp[tiflash] table:t1 keep order:false" ], "Warn": null }, { - "SQL": "explain select id from t1 order by vec_l2_norm(vec) limit 10", + "SQL": "explain format = 'brief' select id from t1 order by vec_l2_norm(vec) limit 10", "Plan": [ - "TopN_10 10.00 root Column#9, offset:0, count:10", - "└─TableReader_22 10.00 root MppVersion: 3, data:ExchangeSender_21", - " └─ExchangeSender_21 10.00 mpp[tiflash] ExchangeType: PassThrough", - " └─TopN_20 10.00 mpp[tiflash] Column#9, offset:0, count:10", - " └─Projection_19 10.00 mpp[tiflash] test.t1.id, vec_l2_norm(test.t1.vec)->Column#9", - " └─TableFullScan_17 6000.00 mpp[tiflash] table:t1 keep order:false" + "TopN 10.00 root Column#9, offset:0, count:10", + "└─TableReader 10.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 10.00 mpp[tiflash] ExchangeType: PassThrough", + " └─TopN 10.00 mpp[tiflash] Column#9, offset:0, count:10", + " └─Projection 10.00 mpp[tiflash] test.t1.id, vec_l2_norm(test.t1.vec)->Column#9", + " └─TableFullScan 6000.00 mpp[tiflash] table:t1 keep order:false" ], "Warn": null }, { - "SQL": "explain select id from t1 order by MOD(a, 3) limit 10", + "SQL": "explain format = 'brief' select id from t1 order by MOD(a, 3) limit 10", "Plan": [ - "Projection_23 10.00 root test.t1.id", - "└─TopN_10 10.00 root Column#9, offset:0, count:10", - " └─Projection_24 10.00 root test.t1.id, test.t1.a, mod(test.t1.a, 3)->Column#9", - " └─TableReader_20 10.00 root MppVersion: 3, data:ExchangeSender_19", - " └─ExchangeSender_19 10.00 mpp[tiflash] ExchangeType: PassThrough", - " └─Projection_21 10.00 mpp[tiflash] test.t1.id, test.t1.a", - " └─TopN_18 10.00 mpp[tiflash] Column#8, offset:0, count:10", - " └─Projection_22 6000.00 mpp[tiflash] test.t1.id, test.t1.a, mod(test.t1.a, 3)->Column#8", - " └─TableFullScan_16 6000.00 mpp[tiflash] table:t1 keep order:false" + "Projection 10.00 root test.t1.id", + "└─TopN 10.00 root Column#9, offset:0, count:10", + " └─Projection 10.00 root test.t1.id, test.t1.a, mod(test.t1.a, 3)->Column#9", + " └─TableReader 10.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 10.00 mpp[tiflash] ExchangeType: PassThrough", + " └─Projection 10.00 mpp[tiflash] test.t1.id, test.t1.a", + " └─TopN 10.00 mpp[tiflash] Column#8, offset:0, count:10", + " └─Projection 6000.00 mpp[tiflash] test.t1.id, test.t1.a, mod(test.t1.a, 3)->Column#8", + " └─TableFullScan 6000.00 mpp[tiflash] table:t1 keep order:false" ], "Warn": null }, { - "SQL": "explain select id, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", + "SQL": "explain format = 'brief' select id, vec_cosine_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", "Plan": [ - "Projection_6 10.00 root test.t1.id, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#7", - "└─TopN_10 10.00 root Column#10, offset:0, count:10", - " └─TableReader_28 10.00 root MppVersion: 3, data:ExchangeSender_27", - " └─ExchangeSender_27 10.00 mpp[tiflash] ExchangeType: PassThrough", - " └─TopN_26 10.00 mpp[tiflash] Column#10, offset:0, count:10", - " └─Projection_25 10.00 mpp[tiflash] test.t1.id, test.t1.vec, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#10", - " └─TableFullScan_24 10.00 mpp[tiflash] table:t1, index:idx_embedding(vec) keep order:false, annIndex:COSINE(vec..[1,1,1], limit:10)" + "Projection 10.00 root test.t1.id, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#7", + "└─TopN 10.00 root Column#10, offset:0, count:10", + " └─TableReader 10.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 10.00 mpp[tiflash] ExchangeType: PassThrough", + " └─TopN 10.00 mpp[tiflash] Column#10, offset:0, count:10", + " └─Projection 10.00 mpp[tiflash] test.t1.id, test.t1.vec, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#10", + " └─TableFullScan 10.00 mpp[tiflash] table:t1, index:idx_embedding(vec) keep order:false, annIndex:COSINE(vec..[1,1,1], limit:10)" ], "Warn": null }, { - "SQL": "explain select id, vec_l1_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", + "SQL": "explain format = 'brief' select id, vec_l1_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", "Plan": [ - "Projection_6 10.00 root test.t1.id, vec_l1_distance(test.t1.vec, [1,1,1])->Column#7", - "└─TopN_9 10.00 root Column#9, offset:0, count:10", - " └─TableReader_22 10.00 root MppVersion: 3, data:ExchangeSender_21", - " └─ExchangeSender_21 10.00 mpp[tiflash] ExchangeType: PassThrough", - " └─TopN_20 10.00 mpp[tiflash] Column#9, offset:0, count:10", - " └─Projection_19 10.00 mpp[tiflash] test.t1.id, test.t1.vec, vec_l1_distance(test.t1.vec, [1,1,1])->Column#9", - " └─TableFullScan_17 6000.00 mpp[tiflash] table:t1 keep order:false" + "Projection 10.00 root test.t1.id, vec_l1_distance(test.t1.vec, [1,1,1])->Column#7", + "└─TopN 10.00 root Column#9, offset:0, count:10", + " └─TableReader 10.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 10.00 mpp[tiflash] ExchangeType: PassThrough", + " └─TopN 10.00 mpp[tiflash] Column#9, offset:0, count:10", + " └─Projection 10.00 mpp[tiflash] test.t1.id, test.t1.vec, vec_l1_distance(test.t1.vec, [1,1,1])->Column#9", + " └─TableFullScan 6000.00 mpp[tiflash] table:t1 keep order:false" ], "Warn": null }, { - "SQL": "explain select id, vec_l2_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", + "SQL": "explain format = 'brief' select id, vec_l2_distance(vec, '[1,1,1]') as d from t1 order by d limit 10", "Plan": [ - "Projection_6 10.00 root test.t1.id, vec_l2_distance(test.t1.vec, [1,1,1])->Column#7", - "└─TopN_9 10.00 root Column#9, offset:0, count:10", - " └─TableReader_22 10.00 root MppVersion: 3, data:ExchangeSender_21", - " └─ExchangeSender_21 10.00 mpp[tiflash] ExchangeType: PassThrough", - " └─TopN_20 10.00 mpp[tiflash] Column#9, offset:0, count:10", - " └─Projection_19 10.00 mpp[tiflash] test.t1.id, test.t1.vec, vec_l2_distance(test.t1.vec, [1,1,1])->Column#9", - " └─TableFullScan_17 6000.00 mpp[tiflash] table:t1 keep order:false" + "Projection 10.00 root test.t1.id, vec_l2_distance(test.t1.vec, [1,1,1])->Column#7", + "└─TopN 10.00 root Column#9, offset:0, count:10", + " └─TableReader 10.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 10.00 mpp[tiflash] ExchangeType: PassThrough", + " └─TopN 10.00 mpp[tiflash] Column#9, offset:0, count:10", + " └─Projection 10.00 mpp[tiflash] test.t1.id, test.t1.vec, vec_l2_distance(test.t1.vec, [1,1,1])->Column#9", + " └─TableFullScan 6000.00 mpp[tiflash] table:t1 keep order:false" ], "Warn": null }, { - "SQL": "explain select id, vec_negative_inner_product(vec, '[1,1,1]') as d from t1 order by d limit 10", + "SQL": "explain format = 'brief' select id, vec_negative_inner_product(vec, '[1,1,1]') as d from t1 order by d limit 10", "Plan": [ - "Projection_6 10.00 root test.t1.id, vec_negative_inner_product(test.t1.vec, [1,1,1])->Column#7", - "└─TopN_9 10.00 root Column#9, offset:0, count:10", - " └─TableReader_22 10.00 root MppVersion: 3, data:ExchangeSender_21", - " └─ExchangeSender_21 10.00 mpp[tiflash] ExchangeType: PassThrough", - " └─TopN_20 10.00 mpp[tiflash] Column#9, offset:0, count:10", - " └─Projection_19 10.00 mpp[tiflash] test.t1.id, test.t1.vec, vec_negative_inner_product(test.t1.vec, [1,1,1])->Column#9", - " └─TableFullScan_17 6000.00 mpp[tiflash] table:t1 keep order:false" + "Projection 10.00 root test.t1.id, vec_negative_inner_product(test.t1.vec, [1,1,1])->Column#7", + "└─TopN 10.00 root Column#9, offset:0, count:10", + " └─TableReader 10.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 10.00 mpp[tiflash] ExchangeType: PassThrough", + " └─TopN 10.00 mpp[tiflash] Column#9, offset:0, count:10", + " └─Projection 10.00 mpp[tiflash] test.t1.id, test.t1.vec, vec_negative_inner_product(test.t1.vec, [1,1,1])->Column#9", + " └─TableFullScan 6000.00 mpp[tiflash] table:t1 keep order:false" ], "Warn": null }, { - "SQL": "explain select id, vec_dims(vec) as d from t1 order by d limit 10", + "SQL": "explain format = 'brief' select id, vec_dims(vec) as d from t1 order by d limit 10", "Plan": [ - "Projection_6 10.00 root test.t1.id, vec_dims(test.t1.vec)->Column#7", - "└─TopN_9 10.00 root Column#9, offset:0, count:10", - " └─TableReader_21 10.00 root MppVersion: 3, data:ExchangeSender_20", - " └─ExchangeSender_20 10.00 mpp[tiflash] ExchangeType: PassThrough", - " └─TopN_19 10.00 mpp[tiflash] Column#9, offset:0, count:10", - " └─Projection_18 10.00 mpp[tiflash] test.t1.id, test.t1.vec, vec_dims(test.t1.vec)->Column#9", - " └─TableFullScan_16 6000.00 mpp[tiflash] table:t1 keep order:false" + "Projection 10.00 root test.t1.id, vec_dims(test.t1.vec)->Column#7", + "└─TopN 10.00 root Column#9, offset:0, count:10", + " └─TableReader 10.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 10.00 mpp[tiflash] ExchangeType: PassThrough", + " └─TopN 10.00 mpp[tiflash] Column#9, offset:0, count:10", + " └─Projection 10.00 mpp[tiflash] test.t1.id, test.t1.vec, vec_dims(test.t1.vec)->Column#9", + " └─TableFullScan 6000.00 mpp[tiflash] table:t1 keep order:false" ], "Warn": null }, { - "SQL": "explain select id, vec_l2_norm(vec) as d from t1 order by d limit 10", + "SQL": "explain format = 'brief' select id, vec_l2_norm(vec) as d from t1 order by d limit 10", "Plan": [ - "Projection_6 10.00 root test.t1.id, vec_l2_norm(test.t1.vec)->Column#7", - "└─TopN_9 10.00 root Column#9, offset:0, count:10", - " └─TableReader_21 10.00 root MppVersion: 3, data:ExchangeSender_20", - " └─ExchangeSender_20 10.00 mpp[tiflash] ExchangeType: PassThrough", - " └─TopN_19 10.00 mpp[tiflash] Column#9, offset:0, count:10", - " └─Projection_18 10.00 mpp[tiflash] test.t1.id, test.t1.vec, vec_l2_norm(test.t1.vec)->Column#9", - " └─TableFullScan_16 6000.00 mpp[tiflash] table:t1 keep order:false" + "Projection 10.00 root test.t1.id, vec_l2_norm(test.t1.vec)->Column#7", + "└─TopN 10.00 root Column#9, offset:0, count:10", + " └─TableReader 10.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 10.00 mpp[tiflash] ExchangeType: PassThrough", + " └─TopN 10.00 mpp[tiflash] Column#9, offset:0, count:10", + " └─Projection 10.00 mpp[tiflash] test.t1.id, test.t1.vec, vec_l2_norm(test.t1.vec)->Column#9", + " └─TableFullScan 6000.00 mpp[tiflash] table:t1 keep order:false" ], "Warn": null }, { - "SQL": "explain select id, MOD(a, 3) as d from t1 order by d limit 10", + "SQL": "explain format = 'brief' select id, MOD(a, 3) as d from t1 order by d limit 10", "Plan": [ - "Projection_6 10.00 root test.t1.id, mod(test.t1.a, 3)->Column#7", - "└─Projection_22 10.00 root test.t1.id, test.t1.a", - " └─TopN_9 10.00 root Column#9, offset:0, count:10", - " └─Projection_23 10.00 root test.t1.id, test.t1.a, mod(test.t1.a, 3)->Column#9", - " └─TableReader_19 10.00 root MppVersion: 3, data:ExchangeSender_18", - " └─ExchangeSender_18 10.00 mpp[tiflash] ExchangeType: PassThrough", - " └─Projection_20 10.00 mpp[tiflash] test.t1.id, test.t1.a", - " └─TopN_17 10.00 mpp[tiflash] Column#8, offset:0, count:10", - " └─Projection_21 6000.00 mpp[tiflash] test.t1.id, test.t1.a, mod(test.t1.a, 3)->Column#8", - " └─TableFullScan_15 6000.00 mpp[tiflash] table:t1 keep order:false" + "Projection 10.00 root test.t1.id, mod(test.t1.a, 3)->Column#7", + "└─Projection 10.00 root test.t1.id, test.t1.a", + " └─TopN 10.00 root Column#9, offset:0, count:10", + " └─Projection 10.00 root test.t1.id, test.t1.a, mod(test.t1.a, 3)->Column#9", + " └─TableReader 10.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 10.00 mpp[tiflash] ExchangeType: PassThrough", + " └─Projection 10.00 mpp[tiflash] test.t1.id, test.t1.a", + " └─TopN 10.00 mpp[tiflash] Column#8, offset:0, count:10", + " └─Projection 6000.00 mpp[tiflash] test.t1.id, test.t1.a, mod(test.t1.a, 3)->Column#8", + " └─TableFullScan 6000.00 mpp[tiflash] table:t1 keep order:false" ], "Warn": null }, { - "SQL": "explain select * from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", + "SQL": "explain format = 'brief' select * from t1 order by vec_cosine_distance(vec, '[1,1,1]') limit 10", "Plan": [ - "TopN_10 10.00 root Column#9, offset:0, count:10", - "└─TableReader_28 10.00 root MppVersion: 3, data:ExchangeSender_27", - " └─ExchangeSender_27 10.00 mpp[tiflash] ExchangeType: PassThrough", - " └─TopN_26 10.00 mpp[tiflash] Column#9, offset:0, count:10", - " └─Projection_25 10.00 mpp[tiflash] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#9", - " └─TableFullScan_24 10.00 mpp[tiflash] table:t1, index:idx_embedding(vec) keep order:false, annIndex:COSINE(vec..[1,1,1], limit:10)" + "TopN 10.00 root Column#9, offset:0, count:10", + "└─TableReader 10.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 10.00 mpp[tiflash] ExchangeType: PassThrough", + " └─TopN 10.00 mpp[tiflash] Column#9, offset:0, count:10", + " └─Projection 10.00 mpp[tiflash] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d, vec_cosine_distance(test.t1.vec, [1,1,1])->Column#9", + " └─TableFullScan 10.00 mpp[tiflash] table:t1, index:idx_embedding(vec) keep order:false, annIndex:COSINE(vec..[1,1,1], limit:10)" ], "Warn": null }, { - "SQL": "explain select * from t1 order by vec_l1_distance(vec, '[1,1,1]') limit 10", + "SQL": "explain format = 'brief' select * from t1 order by vec_l1_distance(vec, '[1,1,1]') limit 10", "Plan": [ - "TopN_9 10.00 root Column#8, offset:0, count:10", - "└─TableReader_22 10.00 root MppVersion: 3, data:ExchangeSender_21", - " └─ExchangeSender_21 10.00 mpp[tiflash] ExchangeType: PassThrough", - " └─TopN_20 10.00 mpp[tiflash] Column#8, offset:0, count:10", - " └─Projection_19 10.00 mpp[tiflash] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d, vec_l1_distance(test.t1.vec, [1,1,1])->Column#8", - " └─TableFullScan_17 6000.00 mpp[tiflash] table:t1 keep order:false" + "TopN 10.00 root Column#8, offset:0, count:10", + "└─TableReader 10.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 10.00 mpp[tiflash] ExchangeType: PassThrough", + " └─TopN 10.00 mpp[tiflash] Column#8, offset:0, count:10", + " └─Projection 10.00 mpp[tiflash] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d, vec_l1_distance(test.t1.vec, [1,1,1])->Column#8", + " └─TableFullScan 6000.00 mpp[tiflash] table:t1 keep order:false" ], "Warn": null }, { - "SQL": "explain select * from t1 order by vec_l2_distance(vec, '[1,1,1]') limit 10", + "SQL": "explain format = 'brief' select * from t1 order by vec_l2_distance(vec, '[1,1,1]') limit 10", "Plan": [ - "TopN_9 10.00 root Column#8, offset:0, count:10", - "└─TableReader_22 10.00 root MppVersion: 3, data:ExchangeSender_21", - " └─ExchangeSender_21 10.00 mpp[tiflash] ExchangeType: PassThrough", - " └─TopN_20 10.00 mpp[tiflash] Column#8, offset:0, count:10", - " └─Projection_19 10.00 mpp[tiflash] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d, vec_l2_distance(test.t1.vec, [1,1,1])->Column#8", - " └─TableFullScan_17 6000.00 mpp[tiflash] table:t1 keep order:false" + "TopN 10.00 root Column#8, offset:0, count:10", + "└─TableReader 10.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 10.00 mpp[tiflash] ExchangeType: PassThrough", + " └─TopN 10.00 mpp[tiflash] Column#8, offset:0, count:10", + " └─Projection 10.00 mpp[tiflash] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d, vec_l2_distance(test.t1.vec, [1,1,1])->Column#8", + " └─TableFullScan 6000.00 mpp[tiflash] table:t1 keep order:false" ], "Warn": null }, { - "SQL": "explain select * from t1 order by vec_negative_inner_product(vec, '[1,1,1]') limit 10", + "SQL": "explain format = 'brief' select * from t1 order by vec_negative_inner_product(vec, '[1,1,1]') limit 10", "Plan": [ - "TopN_9 10.00 root Column#8, offset:0, count:10", - "└─TableReader_22 10.00 root MppVersion: 3, data:ExchangeSender_21", - " └─ExchangeSender_21 10.00 mpp[tiflash] ExchangeType: PassThrough", - " └─TopN_20 10.00 mpp[tiflash] Column#8, offset:0, count:10", - " └─Projection_19 10.00 mpp[tiflash] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d, vec_negative_inner_product(test.t1.vec, [1,1,1])->Column#8", - " └─TableFullScan_17 6000.00 mpp[tiflash] table:t1 keep order:false" + "TopN 10.00 root Column#8, offset:0, count:10", + "└─TableReader 10.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 10.00 mpp[tiflash] ExchangeType: PassThrough", + " └─TopN 10.00 mpp[tiflash] Column#8, offset:0, count:10", + " └─Projection 10.00 mpp[tiflash] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d, vec_negative_inner_product(test.t1.vec, [1,1,1])->Column#8", + " └─TableFullScan 6000.00 mpp[tiflash] table:t1 keep order:false" ], "Warn": null }, { - "SQL": "explain select * from t1 order by vec_dims(vec) limit 10", + "SQL": "explain format = 'brief' select * from t1 order by vec_dims(vec) limit 10", "Plan": [ - "TopN_9 10.00 root Column#8, offset:0, count:10", - "└─TableReader_21 10.00 root MppVersion: 3, data:ExchangeSender_20", - " └─ExchangeSender_20 10.00 mpp[tiflash] ExchangeType: PassThrough", - " └─TopN_19 10.00 mpp[tiflash] Column#8, offset:0, count:10", - " └─Projection_18 10.00 mpp[tiflash] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d, vec_dims(test.t1.vec)->Column#8", - " └─TableFullScan_16 6000.00 mpp[tiflash] table:t1 keep order:false" + "TopN 10.00 root Column#8, offset:0, count:10", + "└─TableReader 10.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 10.00 mpp[tiflash] ExchangeType: PassThrough", + " └─TopN 10.00 mpp[tiflash] Column#8, offset:0, count:10", + " └─Projection 10.00 mpp[tiflash] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d, vec_dims(test.t1.vec)->Column#8", + " └─TableFullScan 6000.00 mpp[tiflash] table:t1 keep order:false" ], "Warn": null }, { - "SQL": "explain select * from t1 order by vec_l2_norm(vec) limit 10", + "SQL": "explain format = 'brief' select * from t1 order by vec_l2_norm(vec) limit 10", "Plan": [ - "TopN_9 10.00 root Column#8, offset:0, count:10", - "└─TableReader_21 10.00 root MppVersion: 3, data:ExchangeSender_20", - " └─ExchangeSender_20 10.00 mpp[tiflash] ExchangeType: PassThrough", - " └─TopN_19 10.00 mpp[tiflash] Column#8, offset:0, count:10", - " └─Projection_18 10.00 mpp[tiflash] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d, vec_l2_norm(test.t1.vec)->Column#8", - " └─TableFullScan_16 6000.00 mpp[tiflash] table:t1 keep order:false" + "TopN 10.00 root Column#8, offset:0, count:10", + "└─TableReader 10.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 10.00 mpp[tiflash] ExchangeType: PassThrough", + " └─TopN 10.00 mpp[tiflash] Column#8, offset:0, count:10", + " └─Projection 10.00 mpp[tiflash] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d, vec_l2_norm(test.t1.vec)->Column#8", + " └─TableFullScan 6000.00 mpp[tiflash] table:t1 keep order:false" ], "Warn": null }, { - "SQL": "explain select * from t1 order by MOD(a, 3) limit 10", + "SQL": "explain format = 'brief' select * from t1 order by MOD(a, 3) limit 10", "Plan": [ - "Projection_22 10.00 root test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d", - "└─TopN_9 10.00 root Column#8, offset:0, count:10", - " └─Projection_23 10.00 root test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d, mod(test.t1.a, 3)->Column#8", - " └─TableReader_19 10.00 root MppVersion: 3, data:ExchangeSender_18", - " └─ExchangeSender_18 10.00 mpp[tiflash] ExchangeType: PassThrough", - " └─Projection_20 10.00 mpp[tiflash] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d", - " └─TopN_17 10.00 mpp[tiflash] Column#7, offset:0, count:10", - " └─Projection_21 6000.00 mpp[tiflash] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d, mod(test.t1.a, 3)->Column#7", - " └─TableFullScan_15 6000.00 mpp[tiflash] table:t1 keep order:false" + "Projection 10.00 root test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d", + "└─TopN 10.00 root Column#8, offset:0, count:10", + " └─Projection 10.00 root test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d, mod(test.t1.a, 3)->Column#8", + " └─TableReader 10.00 root MppVersion: 3, data:ExchangeSender", + " └─ExchangeSender 10.00 mpp[tiflash] ExchangeType: PassThrough", + " └─Projection 10.00 mpp[tiflash] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d", + " └─TopN 10.00 mpp[tiflash] Column#7, offset:0, count:10", + " └─Projection 6000.00 mpp[tiflash] test.t1.id, test.t1.vec, test.t1.a, test.t1.b, test.t1.c, test.t1.d, mod(test.t1.a, 3)->Column#7", + " └─TableFullScan 6000.00 mpp[tiflash] table:t1 keep order:false" ], "Warn": null } ] } -] \ No newline at end of file +] diff --git a/pkg/planner/core/integration_test.go b/pkg/planner/core/integration_test.go index 41a8071868e16..91750c6346ef2 100644 --- a/pkg/planner/core/integration_test.go +++ b/pkg/planner/core/integration_test.go @@ -2181,11 +2181,11 @@ func TestVirtualExprPushDown(t *testing.T) { // TopN to tikv. rows := [][]any{ - {"TopN_7", "root", "test.t.c2, offset:0, count:2"}, - {"└─TableReader_13", "root", "data:TableFullScan_12"}, - {" └─TableFullScan_12", "cop[tikv]", "keep order:false, stats:pseudo"}, + {"TopN", "root", "test.t.c2, offset:0, count:2"}, + {"└─TableReader", "root", "data:TableFullScan"}, + {" └─TableFullScan", "cop[tikv]", "keep order:false, stats:pseudo"}, } - tk.MustQuery("explain select * from t order by c2 limit 2;").CheckAt([]int{0, 2, 4}, rows) + tk.MustQuery("explain format='brief' select * from t order by c2 limit 2;").CheckAt([]int{0, 2, 4}, rows) // Projection to tikv. rows = [][]any{ @@ -2217,11 +2217,11 @@ func TestVirtualExprPushDown(t *testing.T) { // TopN to tiflash. rows = [][]any{ - {"TopN_7", "root", "test.t.c2, offset:0, count:2"}, - {"└─TableReader_15", "root", "data:TableFullScan_14"}, - {" └─TableFullScan_14", "cop[tiflash]", "keep order:false, stats:pseudo"}, + {"TopN", "root", "test.t.c2, offset:0, count:2"}, + {"└─TableReader", "root", "data:TableFullScan"}, + {" └─TableFullScan", "cop[tiflash]", "keep order:false, stats:pseudo"}, } - tk.MustQuery("explain select * from t order by c2 limit 2;").CheckAt([]int{0, 2, 4}, rows) + tk.MustQuery("explain format='brief' select * from t order by c2 limit 2;").CheckAt([]int{0, 2, 4}, rows) // Projection to tiflash. rows = [][]any{ diff --git a/pkg/planner/core/operator/logicalop/logical_projection.go b/pkg/planner/core/operator/logicalop/logical_projection.go index 69d3d93a58417..8e6acd75e42b8 100644 --- a/pkg/planner/core/operator/logicalop/logical_projection.go +++ b/pkg/planner/core/operator/logicalop/logical_projection.go @@ -193,6 +193,7 @@ func (p *LogicalProjection) PushDownTopN(topNLogicalPlan base.LogicalPlan, opt * if slices.ContainsFunc(p.Exprs, expression.HasAssignSetVarFunc) { return p.BaseLogicalPlan.PushDownTopN(topN, opt) } + if topN != nil { exprCtx := p.SCtx().GetExprCtx() substitutedExprs := make([]expression.Expression, 0, len(topN.ByItems)) @@ -202,12 +203,23 @@ func (p *LogicalProjection) PushDownTopN(topNLogicalPlan base.LogicalPlan, opt * // after substituting, if the order-by expression is un-deterministic like 'order by rand()', stop pushing down. return p.BaseLogicalPlan.PushDownTopN(topN, opt) } + // if topN.ByItems contains a column(with ID=0) generated by projection, + // projection will prevent the optimizer from pushing topN down. + cols := expression.ExtractColumns(substituted) + for _, col := range cols { + if col.ID == 0 && p.Schema().Contains(col) { + // check whether the column is generated by projection + if !p.Children()[0].Schema().Contains(col) { + p.Children()[0] = p.Children()[0].PushDownTopN(nil, opt) + return topN.AttachChild(p, opt) + } + } + } substitutedExprs = append(substitutedExprs, substituted) } for i, by := range topN.ByItems { by.Expr = substitutedExprs[i] } - // remove meaningless constant sort items. for i := len(topN.ByItems) - 1; i >= 0; i-- { switch topN.ByItems[i].Expr.(type) { @@ -215,22 +227,11 @@ func (p *LogicalProjection) PushDownTopN(topNLogicalPlan base.LogicalPlan, opt * topN.ByItems = slices.Delete(topN.ByItems, i, i+1) } } - - // if topN.ByItems contains a column(with ID=0) generated by projection, projection will prevent the optimizer from pushing topN down. - for _, by := range topN.ByItems { - cols := expression.ExtractColumns(by.Expr) - for _, col := range cols { - if col.ID == 0 && p.Schema().Contains(col) { - // check whether the column is generated by projection - if !p.Children()[0].Schema().Contains(col) { - p.Children()[0] = p.Children()[0].PushDownTopN(nil, opt) - return topN.AttachChild(p, opt) - } - } - } - } + p.Children()[0] = p.Children()[0].PushDownTopN(topN, opt) + return p } - p.Children()[0] = p.Children()[0].PushDownTopN(topN, opt) + + p.Children()[0] = p.Children()[0].PushDownTopN(nil, opt) return p } diff --git a/pkg/planner/core/operator/logicalop/logicalop_test/BUILD.bazel b/pkg/planner/core/operator/logicalop/logicalop_test/BUILD.bazel index 05f836890faf9..a4e44563b0c01 100644 --- a/pkg/planner/core/operator/logicalop/logicalop_test/BUILD.bazel +++ b/pkg/planner/core/operator/logicalop/logicalop_test/BUILD.bazel @@ -10,7 +10,7 @@ go_test( "plan_execute_test.go", ], flaky = True, - shard_count = 36, + shard_count = 37, deps = [ "//pkg/domain", "//pkg/expression", diff --git a/pkg/planner/core/operator/logicalop/logicalop_test/logical_operator_test.go b/pkg/planner/core/operator/logicalop/logicalop_test/logical_operator_test.go index 9cc74589e353e..6e40cdeaa30ff 100644 --- a/pkg/planner/core/operator/logicalop/logicalop_test/logical_operator_test.go +++ b/pkg/planner/core/operator/logicalop/logicalop_test/logical_operator_test.go @@ -20,6 +20,7 @@ import ( "github.com/pingcap/tidb/pkg/expression" "github.com/pingcap/tidb/pkg/parser/ast" "github.com/pingcap/tidb/pkg/planner/core/operator/logicalop" + "github.com/pingcap/tidb/pkg/testkit" "github.com/pingcap/tidb/pkg/types" "github.com/pingcap/tidb/pkg/util/mock" "github.com/stretchr/testify/require" @@ -103,3 +104,46 @@ func TestLogicalApplyClone(t *testing.T) { require.True(t, clonedApply.EqualConditions[0].FuncName.L == "f2") require.True(t, apply.EqualConditions[0].FuncName.L == "f2") } + +func TestLogicalProjectionPushDownTopN(t *testing.T) { + store := testkit.CreateMockStore(t) + tk := testkit.NewTestKit(t, store) + tk.MustExec("use test;") + tk.MustExec(`CREATE TABLE table_test ( +col16 json DEFAULT NULL, +col17 json DEFAULT NULL +);`) + sql := `explain format='brief' SELECT + s.column16 AS column16, + s.column17 AS column17 +FROM + (SELECT + col16 -> '$[].optUid' AS column16, + JSON_UNQUOTE(JSON_EXTRACT(col17, '$[0].value')) AS column17 + FROM + (SELECT + col16, + col17 + FROM table_test) ta24e + ) AS s +ORDER BY CONVERT(column16 USING GBK) ASC,column17 ASC +LIMIT 0, + 20;` + tk.MustQuery(sql).Check(testkit.Rows( + "Projection 20.00 root Column#4, Column#5", + "└─TopN 20.00 root Column#6, Column#5, offset:0, count:20", + " └─Projection 10000.00 root Column#4, Column#5, convert(cast(Column#4, var_string(16777216)), gbk)->Column#6", + " └─TableReader 10000.00 root data:Projection", + " └─Projection 10000.00 cop[tikv] json_extract(test.table_test.col16, $[].optUid)->Column#4, json_unquote(cast(json_extract(test.table_test.col17, $[0].value), var_string(16777216)))->Column#5", + " └─TableFullScan 10000.00 cop[tikv] table:table_test keep order:false, stats:pseudo")) + tk.MustExec(`INSERT INTO mysql.opt_rule_blacklist VALUES("topn_push_down");`) + tk.MustExec(`admin reload opt_rule_blacklist;`) + tk.MustQuery(sql).Check(testkit.Rows( + "Limit 20.00 root offset:0, count:20", + "└─Projection 20.00 root Column#4, Column#5", + " └─Sort 20.00 root Column#6, Column#5", + " └─Projection 10000.00 root Column#4, Column#5, convert(cast(Column#4, var_string(16777216)), gbk)->Column#6", + " └─TableReader 10000.00 root data:Projection", + " └─Projection 10000.00 cop[tikv] json_extract(test.table_test.col16, $[].optUid)->Column#4, json_unquote(cast(json_extract(test.table_test.col17, $[0].value), var_string(16777216)))->Column#5", + " └─TableFullScan 10000.00 cop[tikv] table:table_test keep order:false, stats:pseudo")) +} diff --git a/tests/integrationtest/r/planner/core/plan.result b/tests/integrationtest/r/planner/core/plan.result index 165c09f59d8ad..2f82c6622fcd1 100644 --- a/tests/integrationtest/r/planner/core/plan.result +++ b/tests/integrationtest/r/planner/core/plan.result @@ -418,6 +418,24 @@ CREATE TABLE `t2`(`c1` set('kn8pu','7et','vekx6','v3','liwrh','q14','1met','nnd5 r0 r1 affected rows: 0 info: +explain format='brief' (select /*+ agg_to_cop()*/ locate(t1.c3, t1.c3) as r0, t1.c3 as r1 from t1 where not( IsNull(t1.c1)) order by r0,r1) union all (select concat_ws(',', t2.c2, t2.c1) as r0, t2.c1 as r1 from t2 order by r0, r1) order by 1 limit 273; +id estRows task access object operator info +TopN 273.00 root Column#9, offset:0, count:273 +└─Union 546.00 root + ├─Projection 273.00 root cast(Column#4, longblob BINARY)->Column#9, planner__core__plan.t1.c3->Column#10 + │ └─Projection 273.00 root locate(planner__core__plan.t1.c3, planner__core__plan.t1.c3)->Column#4, planner__core__plan.t1.c3 + │ └─Projection 273.00 root planner__core__plan.t1.c3 + │ └─TopN 273.00 root Column#11, offset:0, count:273 + │ └─Projection 10000.00 root planner__core__plan.t1.c3, cast(locate(planner__core__plan.t1.c3, planner__core__plan.t1.c3), longblob BINARY)->Column#11 + │ └─TableReader 10000.00 root data:TableFullScan + │ └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo + └─Projection 273.00 root cast(to_binary(Column#8), longblob BINARY)->Column#9, cast(planner__core__plan.t2.c1, tinyblob BINARY)->Column#10 + └─Projection 273.00 root concat_ws(,, cast(planner__core__plan.t2.c2, var_string(5)), planner__core__plan.t2.c1)->Column#8, planner__core__plan.t2.c1 + └─Projection 273.00 root planner__core__plan.t2.c1, planner__core__plan.t2.c2 + └─TopN 273.00 root Column#12, offset:0, count:273 + └─Projection 10000.00 root planner__core__plan.t2.c1, planner__core__plan.t2.c2, cast(to_binary(concat_ws(,, cast(planner__core__plan.t2.c2, var_string(5)), planner__core__plan.t2.c1)), longblob BINARY)->Column#12 + └─IndexReader 10000.00 root index:IndexFullScan + └─IndexFullScan 10000.00 cop[tikv] table:t2, index:k1(c2, c1) keep order:false, stats:pseudo drop table if exists golang1, golang2; CREATE TABLE golang1 ( `fcbpdt` CHAR (8) COLLATE utf8_general_ci NOT NULL, `fcbpsq` VARCHAR (20) COLLATE utf8_general_ci NOT NULL, `procst` char (4) COLLATE utf8_general_ci DEFAULT NULL,`cipstx` VARCHAR (105) COLLATE utf8_general_ci DEFAULT NULL, `cipsst` CHAR (4) COLLATE utf8_general_ci DEFAULT NULL, `dyngtg` VARCHAR(4) COLLATE utf8_general_ci DEFAULT NULL, `blncdt` VARCHAR (8) COLLATE utf8_general_ci DEFAULT NULL, PRIMARY KEY ( fcbpdt, fcbpsq )); insert into golang1 values('20230925','12023092502158016','abc','','','',''); diff --git a/tests/integrationtest/t/planner/core/plan.test b/tests/integrationtest/t/planner/core/plan.test index 4b18143dcc46b..8f35075a3cb65 100644 --- a/tests/integrationtest/t/planner/core/plan.test +++ b/tests/integrationtest/t/planner/core/plan.test @@ -179,6 +179,7 @@ CREATE TABLE `t2`(`c1` set('kn8pu','7et','vekx6','v3','liwrh','q14','1met','nnd5 --enable_info (select /*+ agg_to_cop()*/ locate(t1.c3, t1.c3) as r0, t1.c3 as r1 from t1 where not( IsNull(t1.c1)) order by r0,r1) union all (select concat_ws(',', t2.c2, t2.c1) as r0, t2.c1 as r1 from t2 order by r0, r1) order by 1 limit 273; --disable_info +explain format='brief' (select /*+ agg_to_cop()*/ locate(t1.c3, t1.c3) as r0, t1.c3 as r1 from t1 where not( IsNull(t1.c1)) order by r0,r1) union all (select concat_ws(',', t2.c2, t2.c1) as r0, t2.c1 as r1 from t2 order by r0, r1) order by 1 limit 273; # TestIssue47445