Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id DF40364FCEF for ; Thu, 21 Aug 2008 11:02:07 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 83017-02 for ; Thu, 21 Aug 2008 11:01:58 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mir3-fs.mir3.com (mail.mir3.com [72.11.241.14]) by postgresql.org (Postfix) with ESMTP id D4ED064FCE6 for ; Thu, 21 Aug 2008 11:02:03 -0300 (ADT) Received: MIR3-FS 172.16.1.11 from 172.16.2.68 172.16.2.68 via HTTP with MS-WebStorage 6.0.6249 Received: from archimedes by MIR3-FS; 21 Aug 2008 07:02:00 -0700 Subject: Re: PostgreSQL+Hibernate Performance From: Mark Lewis To: Kranti K K =?UTF-8?Q?Parisa=E2=84=A2?= Cc: Matthew Wakeling , pgsql-performance@postgresql.org In-Reply-To: <4478b4ac0808210003x163e3d22u7fda12bd0e0ffeba@mail.gmail.com> References: <4478b4ac0808200525ia6eabe8q886ac7fbba53ff05@mail.gmail.com> <1219242910.7023.94.camel@archimedes.mir3.com> <4478b4ac0808200810p7eb1f0b2ga307d858a8d94e60@mail.gmail.com> <4478b4ac0808210003x163e3d22u7fda12bd0e0ffeba@mail.gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Organization: MIR3, Inc. Date: Thu, 21 Aug 2008 07:02:00 -0700 Message-Id: <1219327320.7023.142.camel@archimedes.mir3.com> Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200808/247 X-Sequence-Number: 31128 On Thu, 2008-08-21 at 12:33 +0530, Kranti K K Parisa=E2=84=A2 wrote: > On Wed, Aug 20, 2008 at 8:54 PM, Matthew Wakeling > wrote: > On Wed, 20 Aug 2008, Kranti K K Parisa=E2=84=A2 wrote: > creating multiple indexes on same column will effect > performance? > for example: > =20 > index1 : column1, column2, column3 > index2: column1 > index3: column2, > index4: column3 > index5: column1,column2 > =20 > =20 > The sole purpose of indexes is to affect performance. > =20 > However, if you have index1, there is no point in having > index2 or index5. > =20 > Matthew > =20 > Thanks Matthew, >=20 > does that mean i can just have index1, index3, index4? >=20 (trying to get the thread back into newest-comments-last order) Well, yes you can get away with just index1, index3 and index4, and it may well be the optimal solution for you, but it's not entirely clear-cut. It's true that PG can use index1 to satisfy queries of the form "SELECT x FROM y WHERE column1=3Dsomevalue" or "column1=3Da AND column2=3Db". It w= ill not be as fast as an index lookup from a single index, but depending on the size of the tables/indexes and the selectivity of leading column(s) in the index, the difference in speed may be trivial. On the other hand, if you have individual indexes on column1, column2 and column3 but no multi-column index, PG can combine the individual indexes in memory with a bitmap. This is not as fast as a normal lookup in the multi-column index would be, but can still be a big win over not having an index at all. To make an educated decision you might want to read over some of the online documentation about indexes, in particular these two sections: http://www.postgresql.org/docs/8.3/interactive/indexes-multicolumn.html and http://www.postgresql.org/docs/8.3/interactive/indexes-bitmap-scans.html -- Mark