Search code examples
postgresqlhashtable

PostgreSQL hash indexes and inequality


The PostgreSQL documentation states that hash indexes work for equality comparisons.

Hash indexes can only handle simple equality comparisons. 
The query planner will consider using a hash index whenever an 
indexed column is involved in a comparison using the = operator. 

Does this mean that it can also be used when testing for inequality? i.e. !=


Solution

  • No, that won't work.

    How would you use a hash table to efficiently find all items not equal to a certain value?