Use Index Hint - not supported for UPDATE nor DELETE


#1

Seems like USE INDEX (as an alternative to USE KEYS) could be very useful for an UPDATE or DELETE call. It’s supported for SELECT.


#2

USE INDEX is hint. You still need predicate and it will validate the index so that no wrong results are possible. UPDATE/DELETE have option.

create index ix1 on default(type);
update default use index(ix1) set name ="abc" WHERE type IS NOT NULL;
delete FROM default use index(ix1) WHERE type IS NOT NULL;

#3

Not according to the documentation (nor SDK - DeleteUsePath / UpdateUsePath):
https://developer.couchbase.com/documentation/server/5.1/n1ql/n1ql-language-reference/delete.html
https://developer.couchbase.com/documentation/server/5.1/n1ql/n1ql-language-reference/update.html

For SELECT, AsPath is used (which extends HintPath which KeysPath, which permits both)


#4

We will fix the documentation cc @guy.klages


#5

Not supported in SDK’s either, unless that’s coming with new revisions?


#6

N1QL documentation DOC-3475 .
@ingenthr will be able to answer for SDKs


#8

Using the SDK, it seems we can’t apply 2 of these…

AsPath.useIndex() and AsPath.useKeys() return LetPath so they can’t be piled on top of eachother in the builder… By hacking around, they can’t be done outside the builder either - last one wins…


#9

We’ll check that out. If we’ve missed something in the builder, there is always a lowest-common-denominator path of string. Updates coming.