Received: from sss2.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.10.1/8.10.1) with ESMTP id e73KLdG78799 for ; Thu, 3 Aug 2000 16:21:39 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss2.sss.pgh.pa.us (8.9.3/8.9.3) with ESMTP id QAA19360; Thu, 3 Aug 2000 16:21:30 -0400 (EDT) To: Alexaki Sofia cc: pgsql-sql@postgresql.org Subject: Re: A question about indexes... In-reply-to: References: Comments: In-reply-to Alexaki Sofia message dated "Thu, 03 Aug 2000 20:51:44 +0300" Date: Thu, 03 Aug 2000 16:21:30 -0400 Message-ID: <19357.965334090@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200008/31 Alexaki Sofia writes: > I can either define the field id as a Primary Key or create an Btree index > on it. What is more effient?? > From my test I see that creating Btree index is a bit faster!!. I think you're seeing things. Declaring a field primary key creates a btree index on it (and also enables UNIQUE and NOT NULL checks, but those don't affect the speed of lookups). There isn't going to be any difference between the two ways of doing it --- whatever difference you measured was due to other factors, eg, disk pages already in cache. As for your other point I'd generally recommend btree over hash indexes. The btree code is much more thoroughly tested, supports concurrent updates which hash indexes don't, and allows order-based index scans which hash doesn't. I don't see any redeeming social value in a hash index, actually... regards, tom lane