Hi,
I have a following data in the bucket:
{“n”:“abc def”,“d”:1551918525,“t”:[“abc”, “def”],“l”:“pl”,“c”:2094,“y”:2019,“m”:3}
And the following index
CREATE INDEX tagindexwithid
ON itemdata
(d
,(distinct (array k
for k
in t
end)),(meta().id
)) PARTITION BY hash(d
)
I would expect that folliowing query :
select meta().id, d from itemdata m where d >= 1551916800 and d < 1557705600 AND ((((ANY t IN t SATISFIES t like "abc%" END )) AND NOT ((ANY t IN t SATISFIES t like "xxx%" END ))))
would not need to perform fetch, as all data is in index, however the query plan states, that the fetch is performed.
How to modify the index to make fetch unnecessary and for best performance of this query ?
Thank you.
Piotr
current query plan:
{
"#operator": "Sequence",
"~children": [
{
"#operator": "DistinctScan",
"scan": {
"#operator": "IndexScan3",
"as": "m",
"index": "tagindexwithid",
"index_id": "b55e0ee9e13f6264",
"index_projection": {
"primary_key": true
},
"keyspace": "itemdata",
"namespace": "default",
"spans": [
{
"exact": true,
"range": [
{
"high": "1557705600",
"inclusion": 1,
"low": "1551916800"
},
{
"high": "\"abd\"",
"inclusion": 1,
"low": "\"abc\""
}
]
}
],
"using": "gsi"
}
},
{
"#operator": "Fetch",
"as": "m",
"keyspace": "itemdata",
"namespace": "default"
},
{
"#operator": "Parallel",
"~child": {
"#operator": "Sequence",
"~children": [
{
"#operator": "Filter",
"condition": "(((1551916800 <= (`m`.`d`)) and ((`m`.`d`) < 1557705600)) and (any `t` in (`m`.`t`) satisfies (`t` like \"abc%\") end and (not any `t` in (`m`.`t`) satisfies (`t` like \"xxx%\") end)))"
},
{
"#operator": "InitialProject",
"result_terms": [
{
"expr": "(meta(`m`).`id`)"
},
{
"expr": "(`m`.`d`)"
}
]
},
{
"#operator": "FinalProject"
}
]
}
}
]
}