Re: What is wrong with hashed index usage? - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: What is wrong with hashed index usage?
Date
Msg-id 200206211503.g5LF3PP20126@candle.pha.pa.us
Whole thread Raw
In response to Re: What is wrong with hashed index usage?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: What is wrong with hashed index usage?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > OK, which part of is "demonstrably false"?  I think the old "should
> > generally be preferred" is too vague.  No one has come up with a case
> > where hash has shown to be faster, and a lot of cases where it is slower.
>
> The only thing I recall being lots worse is initial index build.
>
> I have not tested it much, but I would expect that hash holds up better
> in the presence of many equal keys than btree does...

I remember three problems:  build time, index size, and concurrency
problems.  I was wondering about the equal key case myself, and assumed
hash may be a win there, but with the concurrency problems, is that even
possible?

OK, I have reworded it.  Is that better?  How about an elog(NOTICE) for
hash use?

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
Index: doc/src/sgml/indices.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/indices.sgml,v
retrieving revision 1.32
diff -c -r1.32 indices.sgml
*** doc/src/sgml/indices.sgml    21 Jun 2002 03:25:53 -0000    1.32
--- doc/src/sgml/indices.sgml    21 Jun 2002 15:00:32 -0000
***************
*** 181,188 ****
  </synopsis>
     <note>
      <para>
!      Testing has shown that hash indexes are slower than btree indexes,
!      and the size and build time for hash indexes is much worse. For
       these reasons, hash index use is discouraged.
      </para>
     </note>
--- 181,188 ----
  </synopsis>
     <note>
      <para>
!      Testing has shown hash indexes to be similar or slower than btree indexes,
!      and the index size and build time for hash indexes is much worse. For
       these reasons, hash index use is discouraged.
      </para>
     </note>
Index: doc/src/sgml/ref/create_index.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/ref/create_index.sgml,v
retrieving revision 1.32
diff -c -r1.32 create_index.sgml
*** doc/src/sgml/ref/create_index.sgml    21 Jun 2002 03:25:53 -0000    1.32
--- doc/src/sgml/ref/create_index.sgml    21 Jun 2002 15:00:32 -0000
***************
*** 330,337 ****
      the <literal>=</literal> operator.
     </para>
     <para>
!      Testing has shown that hash indexes are slower than btree indexes,
!      and the size and build time for hash indexes is much worse. For
       these reasons, hash index use is discouraged.
     </para>

--- 330,337 ----
      the <literal>=</literal> operator.
     </para>
     <para>
!      Testing has shown hash indexes to be similar or slower than btree indexes,
!      and the index size and build time for hash indexes is much worse. For
       these reasons, hash index use is discouraged.
     </para>


pgsql-hackers by date:

Previous
From: Thomas Lockhart
Date:
Subject: Re: ADTs and embedded sql
Next
From: Alessio Bragadini
Date:
Subject: Re: Our archive searching stinks