Re: A question about indexes...

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: A question about indexes...
Дата
Msg-id 19357.965334090@sss.pgh.pa.us
обсуждение исходный текст
Ответ на A question about indexes...  (Alexaki Sofia <alexaki@ics.forth.gr>)
Список pgsql-sql
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


В списке pgsql-sql по дате отправления:

Предыдущее
От: John McKown
Дата:
Сообщение: Re: Extracting data by months
Следующее
От: Mark Volpe
Дата:
Сообщение: Re: PL/pgSQL evaluation order