pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Carlo Stonebanks <stonec.register@sympatico.ca>
To: pgsql-performance@postgresql.org
Subject: Composite keys
Date: Tue, 11 Oct 2011 11:16:07 -0400
Message-ID: <CCB4B01D184042ECBBE456D1ACB185A4@CAPRICA> (raw)

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

view thread (11+ messages)  latest in thread

Message-ID: <CCB4B01D184042ECBBE456D1ACB185A4@CAPRICA>
Permalink:  ../CCB4B01D184042ECBBE456D1ACB185A4@CAPRICA/
Also on:    postgresql.org/message-id/CCB4B01D184042ECBBE456D1ACB185A4@CAPRICA

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: stonec.register@sympatico.ca
  Subject: Re: Composite keys
  In-Reply-To: <CCB4B01D184042ECBBE456D1ACB185A4@CAPRICA>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox