Re: A question about indexes...

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alexaki Sofia <alexaki(at)ics(dot)forth(dot)gr>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: A question about indexes...
Date: 2000-08-03 20:21:30
Message-ID: 19357.965334090@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Alexaki Sofia <alexaki(at)ics(dot)forth(dot)gr> 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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Mark Volpe 2000-08-03 21:52:36 Re: PL/pgSQL evaluation order
Previous Message John McKown 2000-08-03 19:23:34 Re: Extracting data by months