yugabyte/yugabyte-db

[YCQL] Explain plan for index scans omits limit clause

Open

#4,649 建立於 2020年6月2日

在 GitHub 查看
 (1 留言) (0 反應) (1 負責人)C (1,003 fork)batch import
area/ycqlgood first issuekind/enhancementpriority/low

倉庫指標

Star
 (8,229 star)
PR 合併指標
 (平均合併 17天 21小時) (30 天內合併 92 個 PR)

描述

Jira Link: DB-4683

Repro

Set up a table.
create keyspace foo;
use foo;
create table test(h int, r int, v int, primary key(h,r)) with transactions = {'enabled' : true};
create index on test(v);
Insert some rows.
insert into test (h,r,v) values (1,1,1);
insert into test (h,r,v) values (2,2,1);
insert into test (h,r,v) values (2,3,1);
insert into test (h,r,v) values (2,4,2);
insert into test (h,r,v) values (2,5,1);
select * from test where v = 1;
Test explain plan for sequential scan.
explain select * from test where h = 1 limit 1;
 QUERY PLAN
---------------------------------
 Limit
   ->  Range Scan on foo.test
         Key Conditions: (h = 1)
Test explain plan for index scan.
explain select * from test where v = 1 limit 1;
 QUERY PLAN
--------------------------------------------------
 Index Only Scan using foo.test_v_idx on foo.test
   Key Conditions: (v = 1)

^ Limit component missing.

Actual select works as expected.

This is an EXPLAIN issue only.

select * from test where v = 1 limit 1;
 h | r | v
---+---+---
 1 | 1 | 1

(1 rows)

Possible cause.

The function AnalysisResultToPB in pt_select.cc should inspect the child_select instead of (or in addition to) the top level select when checking for a limit_clause (and possibly aggregate).

貢獻者指南