Does it do a full index scan or does it use the values in the JSON vector bounds?
What does the query plan show?
If I use this (equivalent) query on the travel-sample, and create the recommended index on [ airportname, city]
select airport.* from travel-sample.inventory.airport where [ airportname, city] >= ['Albany Intl', 'Albany' ] and [ airportname, city] <= ['Alice Intl' ,'Alice' ]
The resulting query processes only the 9 matching documents. Even without specifying USE INDEX. (there are 1968 airport documents in the colllection).
And look at the range used in the query - it’s exactly what your “index API” would use.
"~children": [
{
"#operator": "IndexScan3",
"#stats": {
"#itemsIn": 9,
"#itemsOut": 9,
"#phaseSwitches": 39,
"execTime": "24.127µs",
"kernTime": "2.825µs",
"servTime": "1.239574ms"
},
"bucket": "travel-sample",
"index": "adv_airportnamecity",
"index_id": "b24708afc103be3f",
"index_projection": {
"primary_key": true
},
"keyspace": "airport",
"namespace": "default",
"optimizer_estimates": {
"cardinality": 1.000000000000183,
"cost": 12.181079088630932,
"fr_cost": 12.1810790886309,
"size": 12
},
"scope": "inventory",
"spans": [
{
"exact": true,
"range": [
{
"high": "[\"Alice Intl\", \"Alice\"]",
"inclusion": 3,
"index_key": "[`airportname`, `city`]",
"low": "[\"Albany Intl\", \"Albany\"]"
}
]
}
],