Multi-key indexes - Mailing list pgsql-general

From Culley Harrelson
Subject Multi-key indexes
Date
Msg-id 9aq40k$2v8g$1@news.tht.net
Whole thread Raw
List pgsql-general
Hi, I wanted to verify the behavior of multi-key indexes.  I have this
table:

create table fe_group_member(
 group_id int4 not null references fe_group(group_id) on delete cascade,
 user_id int4 not null references fe_user(user_id) on delete cascade,
 ins_date timestamp not null default 'now',
 primary key(group_id, user_id)
);

Now if I do:

select * from fe_group_member where group_id = 1;

I think the index created by the primary key will be used.  Is this correct?
And if I do:

select * from fe_group_member where user_id= 1;

then the primary key index will not be used and I need to create an index on
user_id for better performance.  Do I have this right?

Culley








pgsql-general by date:

Previous
From: Joel Burton
Date:
Subject: Re: [DOCS] Better Features document?
Next
From: The Hermit Hacker
Date:
Subject: Re: Re: speed on Postgresql compared to Mysql