I am wondering what the (side-) effects are if you create an index on a column/columns which is/are already covered by a unique consraint.
drop table if exists person;
create table person
(
a integer not null,
b integer not null,
unique(a,b)
);
Here, a unique key constraint is put on a,b. I understood that this internally makes two indices: one on a and another on a,b.
Now I create two indices:
create index on person(a);
create index on person(a,b);
What is the effect of this?
table marriage( person1 integer NOT NULL references persons(id), person2 integer NOT NULL references persons(id) , PRIMARY KEY (person1,person2) );In such a case an extra index om (person2,person1) can be helpful in supporting the FK constraints.