From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alexaki Sofia <alexaki@ics.forth.gr>
Cc: pgsql-sql@postgresql.org
Subject: Re: A question about indexes...
Date: Thu, 03 Aug 2000 16:21:30 -0400
Message-ID: <19357.965334090@sss.pgh.pa.us> (raw)
In-Reply-To: <Pine.GSO.4.10.10008032023500.25089-100000@sappho.ics.forth.gr>
References: <Pine.GSO.4.10.10008032023500.25089-100000@sappho.ics.forth.gr>
Alexaki Sofia <alexaki@ics.forth.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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, alexaki@ics.forth.gr
Subject: Re: A question about indexes...
In-Reply-To: <19357.965334090@sss.pgh.pa.us>
References: <Pine.GSO.4.10.10008032023500.25089-100000@sappho.ics.forth.gr> <19357.965334090@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox