Unix Technical Forum

Creating indexes

This is a discussion on Creating indexes within the Pgsql Performance forums, part of the PostgreSQL category; --> Hi, all. I want to ask what type of index is better to create for bigint types. I have ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Performance

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-10-2008, 03:06 PM
Rauan Maemirov
 
Posts: n/a
Default Creating indexes

Hi, all. I want to ask what type of index is better to create for
bigint types. I have table with bigint (bigserial) primary key. What
type is better to use for it? I tried btree and hash, but didn't
notice any differences in execution time. For GiST and GIN there is a
trouble that I must create operator class, so I limited myself to use
btree or hash. But if it's better to use gist or gin, coment are
welcome.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-10-2008, 03:06 PM
Alan Hodgson
 
Posts: n/a
Default Re: Creating indexes

On Thursday 08 May 2008, Rauan Maemirov <rauan1987@gmail.com> wrote:
> Hi, all. I want to ask what type of index is better to create for
> bigint types. I have table with bigint (bigserial) primary key. What
> type is better to use for it? I tried btree and hash, but didn't
> notice any differences in execution time.


A primary key is a unique btree index, and it's as about as good as it gets
for a bigint.

--
Alan

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQBII1oBJmf5OzX07HQRAmIKAJ9nxB9wGstt5zKbB+ff6p ryuTFQ8QCfaPdB
MwQsTwy5d/FjezcAJDGjaZo=
=/Vqe
-----END PGP SIGNATURE-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-10-2008, 03:06 PM
PFC
 
Posts: n/a
Default Re: Creating indexes

> Hi, all. I want to ask what type of index is better to create for
> bigint types. I have table with bigint (bigserial) primary key. What
> type is better to use for it? I tried btree and hash, but didn't
> notice any differences in execution time. For GiST and GIN there is a
> trouble that I must create operator class, so I limited myself to use
> btree or hash. But if it's better to use gist or gin, coment are
> welcome.


If you use BIGINT, I presume you will have lots of different values, in
that case the best one is the btree. It is the most common and most
optimized index type.
GiST's strength is in using indexes for stuff that can't be done with a
simple btree : geometry, full text, ltree, etc, but gist is slower in the
case of indexing a simple value.
GIN indexes are more compact and very fast for reads but updating is very
slow (they are meant for mostly read-only tables).
Hash is a bit of a fossil. Also it does not support range queries, so if
you need that, btree is definitely better.



--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-10-2008, 03:06 PM
Asche
 
Posts: n/a
Default Re: Creating indexes

Hi,

> Hi, all. I want to ask what type of index is better to create for
> bigint types. I have table with bigint (bigserial) primary key. What


http://www.postgresql.org/docs/8.3/s...eatetable.html

PostgreSQL automatically creates an index for each unique constraint
and primary key constraint to enforce uniqueness. Thus, it is not
necessary to create an index explicitly for primary key columns.

> type is better to use for it? I tried btree and hash, but didn't


You already have an index on your bigint primary key. I think it is of
type btree.

Jan
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 05-10-2008, 03:06 PM
Rauan Maemirov
 
Posts: n/a
Default Re: Creating indexes

On May 9, 1:49*am, asche.pub...@mac.com (Asche) wrote:
> Hi,
>
> > Hi, all. I want to ask what type of index is better to create for
> > bigint types. I have table with bigint (bigserial) primary key. What

>
> http://www.postgresql.org/docs/8.3/s...eatetable.html
>
> PostgreSQL automatically creates an index for each unique constraint *
> and primary key constraint to enforce uniqueness. Thus, it is not *
> necessary to create an index explicitly for primary key columns.
>
> > type is better to use for it? I tried btree and hash, but didn't

>
> You already have an index on your bigint primary key. I think it is of *
> type btree.
>
> Jan


Aah, I understand. Thanks to all for detailed response.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:38 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com