Re: Index and performance - Mailing list pgsql-general

From Manfred Koizar
Subject Re: Index and performance
Date
Msg-id 4ouqvus1ig4qsvclh91ugkggkkra9i9nbg@4ax.com
Whole thread Raw
In response to Index and performance  (Andreas Schlegel <schlegelaw@gmx.de>)
List pgsql-general
On Sun, 15 Dec 2002 22:45:49 +0100, Andreas Schlegel
<schlegelaw@gmx.de> wrote:
>The PRIMARY KEY consists of COL1 and COL2. But if I run a query only on
>the not unique COL1 is it better for the query performance to have a
>separate index or is the existence of the primary key sufficient?

*If* the index is used (and if col2 is not extremely wide), the
performance impact of an unused index column shouldn't be noticeable.

However, I have seen cases where the presence of additional index
columns fooled the planner into not choosing the index scan.  The
decision depends mainly on the selectivity of your col1 condition and
on how well the tuples are sorted by col1.

EXPLAIN ANALYZE is your friend.

Servus
 Manfred

pgsql-general by date:

Previous
From: Brian Minton
Date:
Subject: ALTER TABLE vs. CREATE TABLE
Next
From: "Jules Alberts"
Date:
Subject: how to find referenced column and table