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).