Hi,
I am trying to use PREPARED and PARAMETERIZED query for a query like
SELECT key
FROM myBucket
WHERE key
LIKE $keyPattern AND value
IS VALUED
But this does not achieve the gain of execution I am expecting as, the explain do not take into account (I think) the pattern…
The Explain end up showing
{"~children":[{“keyspace”:“core”,“spans”:[{“Range”:{“High”:["[]"],“Low”:["""",“true”],“Inclusion”:1}}],"#operator":“IndexScan”,“using”:“gsi”,“namespace”:“default”,“index”:“coreIndexOnKeyWithValue127-0-0-1-8091”,“covers”:[“cover((meta(core
).id
))”,“cover((core
.key
))”,“cover(((core
.value
) is valued))”]},{"~child":{"~children":[{"#operator":“Filter”,“condition”:"((cover((core
.key
)) like $keyPattern) and cover(((core
.value
) is valued)))"},{"#operator":“InitialProject”,“result_terms”:[{“expr”:“cover((core
.key
))”}]},{"#operator":“FinalProject”}],"#operator":“Sequence”},"#operator":“Parallel”}],"#operator":“Sequence”}
So in effect the range just goes through everything, defeating the use of an index… This makes sense, I guess, as the prepare of this query do not know the value of $keyPattern so can’t work out the right range…
Is there a way to change the query to be able to use PREPARED statement?
Many thanks.