I have a unique constraint over two columns in an association table, e.g.:
CREATE TABLE PersonImage (
id serial PRIMARY KEY,
person_id integer REFERENCES Person (id),
image_id integer REFERENCES Image (id),
CONSTRAINT person_image_uc UNIQUE (person_id, image_id));
Does the constraint make indexes for person_id
and image_id
independently or does it create a unified index?
My aim is make it faster to search through person_id
and image_id
independently by creating indexes, but I don't want to create more overhead if this is automatically done in the constraint.