yugabyte/yugabyte-db
Voir sur GitHub[YCQL] Explain plan for index scans omits limit clause
Open
#4 649 ouverte le 2 juin 2020
area/ycqlgood first issuekind/enhancementpriority/low
Métriques du dépôt
- Stars
- (8 229 stars)
- Métriques de merge PR
- (Merge moyen 17j 21h) (92 PRs mergées en 30 j)
Description
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).