Oleg Bartunov <oleg@sai.msu.su> writes:
> this is interesting question - do we really need commutator to get
> postgres to use index. This is the only reason we created ~~ operator.
AFAIR there is not a requirement to have a commutator link. However
the indexable operation has to be framed as "indexedvar OP constant".
If the natural way to write it is as "constant OP indexedvar" then
you won't get an indexscan unless it can be commuted to the other way.
The same issue arises if you think that the operator might be useful
in joins.
regards, tom lane