Composite keys - Mailing list pgsql-performance

From Carlo Stonebanks
Subject Composite keys
Date
Msg-id CCB4B01D184042ECBBE456D1ACB185A4@CAPRICA
Whole thread Raw
Responses Re: Composite keys
List 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

pgsql-performance by date:

Previous
From: "Kevin Grittner"
Date:
Subject: Re: postgresql query runtime
Next
From: bricklen
Date:
Subject: Re: Rapidly finding maximal rows