Indexing over composite types in Postgres

Viewed 110

Given the following, what can I expect of the resulting index?

CREATE TYPE instant AS (
    epoch_seconds timezonetz,
    nanos         integer
);

CREATE TABLE event AS (
    label      text,
    occurrence instant
);

CREATE INDEX idx_event_occurrence ON event (occurrence);

Will postgres automatically create a composite index over all the fields in instant? Would this index then use the left field as the primary and the right as the secondary? Would there be any reason to do the following instead?

CREATE INDEX idx_event_occurrence ON event (
    (occurrence).epoch_seconds,
    (occurrence).nanos
);
0 Answers
Related