Currently user can specify a hint in the form of USE KEYS, USE INDEX, USE NL, USE HASH in the query text itself, right after a keyspace specification. This is fine for the type of hints that's specific to a keyspace (all the hints we have so far), but awkward for any type of hints that applies to a query block or a statement itself. One such example is ORDERED, which directs the optimizer to use the order of the keyspaces specified in the query (i.e. do not attempt to reorder joins).
Add an infrastructure to add optimizer hints as a comment, which is common in relational databases. A plus sign is needed immediately after the opening of the comment for it to be recognized as optimizer hint:
You can also specify the hints as a JSON object, like:
We plan to support this for SELECT statement for now. Also you cannot use both the legacy style USE INDEX/USE HASH/USE NL hint with the new style INDEX/USE_NL/USE_HASH hint for the same keyspace.