X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 88C6253A2F for ; Tue, 10 May 2005 01:55:27 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 64387-04 for ; Tue, 10 May 2005 04:55:17 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 1E5F45398C for ; Tue, 10 May 2005 01:55:15 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4A4smer006687; Tue, 10 May 2005 00:54:48 -0400 (EDT) To: Neil Conway Cc: "Jim C. Nasby" , Christopher Petrilli , Ying Lu , pgsql-general@postgresql.org, pgsql-performance@postgresql.org Subject: Re: [PERFORM] "Hash index" vs. "b-tree index" (PostgreSQL In-reply-to: <428037A2.4060304@samurai.com> References: <427F6853.90308@cs.concordia.ca> <427F757A.8000407@samurai.com> <59d991c405050908271b55e673@mail.gmail.com> <427F8321.5030702@samurai.com> <20050509163423.GH35026@decibel.org> <427F9211.2090008@samurai.com> <20050509165133.GJ35026@decibel.org> <427FFCD3.1010803@samurai.com> <4407.1115698257@sss.pgh.pa.us> <428037A2.4060304@samurai.com> Comments: In-reply-to Neil Conway message dated "Tue, 10 May 2005 14:25:06 +1000" Date: Tue, 10 May 2005 00:54:48 -0400 Message-ID: <6686.1115700888@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/448 X-Sequence-Number: 77796 Neil Conway writes: > Tom Lane wrote: >> On the other hand, once you reach the target index page, a hash index >> has no better method than linear scan through all the page's index >> entries to find the actually wanted key(s) > I wonder if it would be possible to store the keys in a hash bucket in > sorted order, provided that the necessary ordering is defined for the > index keys -- considering the ubiquity of b+-trees in Postgres, the > chances of an ordering being defined are pretty good. I have a gut reaction against that: it makes hash indexes fundamentally subservient to btrees. We shouldn't bring in concepts that are outside the basic opclass abstraction. However: what about storing the things in hashcode order? Ordering uint32s doesn't seem like any big conceptual problem. I think that efficient implementation of this would require explicitly storing the hash code for each index entry, which we don't do now, but it seems justifiable on multiple grounds --- besides this point, the search could avoid doing the data-type-specific comparison if the hash code isn't equal. There is evidence in the code that indexes used to store more info than what we now think of as a "standard" index tuple. I am not sure when that went away or what it'd cost to bring it back, but it seems worth looking into. regards, tom lane