Skip site navigation (1) Skip section navigation (2)

Composite keys

From: "Carlo Stonebanks" <stonec(dot)register(at)sympatico(dot)ca>
To: <pgsql-performance(at)postgresql(dot)org>
Subject: Composite keys
Date: 2011-10-11 15:16:07
Message-ID: CCB4B01D184042ECBBE456D1ACB185A4@CAPRICA (view raw or flat)
Thread:
Lists: pgsql-performance
Excuse the noob question, I couldn't find any reading material on this
topic.

 

Let's say my_table has two fields, pkey_id and another_id. The primary key
is pkey_id and of course indexed.

 

Then someone adds a composite index on btree(pkey_id, another_id).

 

Question 1) Is there any benefit to having pkey_id in the second index
(assuming the index was created to satisfy some arbitrary WHERE clause)?

 

Question 2) Regardless of the answer to Question 1 - if another_id is not
guaranteed to be unique, whereas pkey_id is - there any value to changing
the order of declaration (more generally, is there a performance impact for
column ordering in btree composite keys?)

 

Thanks,

 

Carlo

Responses

pgsql-performance by date

Next:From: Greg SmithDate: 2011-10-11 15:32:48
Subject: Re: Adding more memory = hugh cpu load
Previous:From: Luca TettamantiDate: 2011-10-11 12:50:55
Subject: Re: Adding more memory = hugh cpu load

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group