n00b
n00b

Reputation: 349

Indexing columns included in a joint primary key

Given a DB with a primary index on the columns foo and bar, is it worthwhile adding an individual index on the single column foo (assuming that most queries are ... WHERE foo = '...')? If it makes a difference, I'm on pgsql.

Upvotes: 1

Views: 111

Answers (1)

Grisha Weintraub
Grisha Weintraub

Reputation: 7996

If index is (foo,bar) - in this order, you don't need another index on foo. Otherwise you do.

Upvotes: 2

Related Questions