On Wed, Dec 27, 2023 at 2:11 PM Wilson, Maria Louise (LARC-E301)[RSES] <m.l.wilson@xxxxxxxx> wrote:
Thanks for the reply!! Having some issues due to nulls…. Any other thoughts?
i=# ALTER TABLE granule_file ADD PRIMARY KEY (granule_uuid, file_id);
ERROR: column "granule_uuid" contains null values
Seems like an odd design for your table. Check if those rows with null value make any sense for your design.
In any case, for performance, you can try a plain index:
CREATE INDEX ON granule_file (granule_uuid);
CREATE INDEX ON granule_file (granule_uuid);
Since you are filtering for granule_uuid first, an index starting with this column seems to make more sense (that is why I made the PK starting with it before).
A composite index is not really necessary, but could help if you get an index-only scan, if you wanna try:
CREATE INDEX ON granule_file (granule_uuid, file_id);
Best regards,
-- Matheus de Oliveira