Received: from localhost (unknown [200.46.204.184]) by developer.postgresql.org (Postfix) with ESMTP id 8DCA62E00B8 for ; Thu, 8 May 2008 17:24:25 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 12401-01-10 for ; Thu, 8 May 2008 17:24:12 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from 30.mail-out.ovh.net (30.mail-out.ovh.net [213.186.62.213]) by developer.postgresql.org (Postfix) with SMTP id 0A8C62E008B for ; Thu, 8 May 2008 17:02:28 -0300 (ADT) Received: (qmail 7458 invoked by uid 503); 8 May 2008 20:02:48 -0000 Received: from unknown (HELO mail243.ha.ovh.net) (213.186.33.59) by 30.mail-out.ovh.net with SMTP; 8 May 2008 20:02:48 -0000 Received: from b0.ovh.net (HELO queue-out) (213.186.33.50) by b0.ovh.net with SMTP; 8 May 2008 20:02:25 -0000 Received: from par69-8-88-161-102-87.fbx.proxad.net (HELO apollo13.peufeu.com) (88.161.102.87) by ns0.ovh.net with SMTP; 8 May 2008 20:02:22 -0000 To: "Rauan Maemirov" , pgsql-performance@postgresql.org Subject: Re: Creating indexes From: PFC Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 MIME-Version: 1.0 References: <050368ea-4090-4d4e-aef7-b9f2ac06da56@x35g2000hsb.googlegroups.com> Content-Transfer-Encoding: 7bit Date: Thu, 08 May 2008 22:08:17 +0200 Message-ID: In-Reply-To: <050368ea-4090-4d4e-aef7-b9f2ac06da56@x35g2000hsb.googlegroups.com> User-Agent: Opera Mail/9.24 (Linux) X-Ovh-Tracer-Id: 6651253700997678632 X-Ovh-Remote: 88.161.102.87 (par69-8-88-161-102-87.fbx.proxad.net) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-Spam-Check: DONE|H 0.5/N X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.659 tagged_above=0 required=5 tests=AWL=0.659 X-Spam-Level: X-Archive-Number: 200805/133 X-Sequence-Number: 30101 > 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.