Skip to content
Advertisement

Querying case-insensitive columns by SQL in Tarantool

We know that string Tarantool indices can be made case-insensitive by specifying the collation option: collation = "unicode_ci". E.g.:

Now we can do a case-insensitive query:

But how to do it using SQL? This doesn’t work:

Neither does this:

There’s a dirty trick with a poor performance (full scan). We don’t want it, do we?

At last, we have one more workaround:

But the question is – does it use the index? Without an index it also works…

Advertisement

Answer

One can check query plan to figure out whether particular index is used or not. To get query plan simply add ‘EXPLAIN QUERY PLAN ‘ prefix to the original query. For instance:

So the answer is ‘yes’, index is used in this case.
As for another example:

Unfortunately collation in this comparison is binary, since index’s collation is ignored. In SQL only column’s collations are considered to be used during comparison. This limitation will be resolved as soon as corresponding issue is closed.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement