Re: Question on indexes - Mailing list pgsql-general

From Laurenz Albe
Subject Re: Question on indexes
Date
Msg-id f8624649dc10bcb5a908f3054b6377e8573ffc12.camel@cybertec.at
Whole thread Raw
In response to Question on indexes  (sud <suds1434@gmail.com>)
List pgsql-general
On Fri, 2024-10-11 at 00:19 +0530, sud wrote:
> I have never used any 'hash index' but saw documents in the past suggesting issues
> around hash index , like WAL doesnt generate for "hash index" which means we can't
> get the hash index back after crash also they are not applied to replicas etc.
> And also these indexes can not be used for range queries , for sorting etc.
>
> However, we are seeing that one of the databases has multiple hash indexes created.
> So I wanted to understand from experts here, if it's advisable in any specific
> scenarios over B-tre despite such downsides?
> Note- Its version 15.4 database.

It is safe to use them, but in my tests I didn't find a realistic case where the were
better than a B-tree index:
https://www.cybertec-postgresql.com/en/postgresql-hash-index-performance/

Keep them if they do the trick for you, but I'd use B-tree indexes instead.

Yours,
Laurenz Albe



pgsql-general by date:

Previous
From: "Efrain J. Berdecia"
Date:
Subject: Re: Question on indexes
Next
From: Thürmann, Andreas
Date:
Subject: Connection between PostgreSQL and SAP HANA database