When querying over many lquery, should I query an array of lqueries or join them using '|'?

195 views Asked by At

When using the ltree PostgreSQL extension, there are these two operators (among others) at our disposal to compare ltree columns to lquerys.

ltree ~ lquery
ltree ? lquery[]

It seems that you should use ~ for single queries and ? for multiple queries. However, you can also join queries with the use of the | logical OR operator.

So, these two are equivalent when it comes to the queried results:

ltree ~ lquery1 || "|" || lquery2
ltree ? {lquery1, lquery2}

Which of these forms should I prefer?

0

There are 0 answers