yugabyte/yugabyte-db

[YCQL] Inaccuracy in Explain query involving Jsonb

Open

#4.529 geöffnet am 20. Mai 2020

Auf GitHub ansehen
 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C (1.003 Forks)batch import
area/ycqlgood first issuekind/enhancementpriority/medium

Repository-Metriken

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

Beschreibung

Jira Link: DB-4671

ycqlsh:mykeyspace> describe test4;

CREATE TABLE mykeyspace.test4 (
    id bigint PRIMARY KEY,
    detail jsonb
) WITH default_time_to_live = 0
    AND transactions = {'enabled': 'true'};
CREATE INDEX index_test4_by_detail_hello_array ON mykeyspace.test4 (detail->'0'->>'hello', id)
    WITH transactions = {'enabled': 'true'};
CREATE INDEX index_test4_by_detail_foo_array ON mykeyspace.test4 (detail->'0'->>'foo', id)
    WITH transactions = {'enabled': 'true'};

ycqlsh:mykeyspace> explain SELECT id FROM mykeyspace.test4 WHERE (detail->0->>'hello') = 'world';

 QUERY PLAN
----------------------------------------------------------------------------------------
 Index Only Scan using mykeyspace.index_test4_by_detail_hello_array on mykeyspace.test4
   Key Conditions: (detail->'0'->>'hello' = 'world')

Note that the query was for detail->0->>'hello'. But the explain plan shows detail->'0'->>'hello'.

  • ->0-> would denote indexing into an array in the json
  • ->'0'-> would denote selecting a sub-field "0" in the json

Contributor Guide