yugabyte/yugabyte-db

[YCQL] Explain plan for index scans omits limit clause

Open

#4.649 geöffnet am 2. Juni 2020

Auf GitHub ansehen
 (1 Kommentar) (0 Reaktionen) (1 zugewiesene Person)C (1.003 Forks)batch import
area/ycqlgood first issuekind/enhancementpriority/low

Repository-Metriken

Stars
 (8.229 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 17T 21h) (92 gemergte PRs in 30 T)

Beschreibung

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

Contributor Guide