Menu

Partitioned tables and join keys, generating weird query plans

Reddit r/PostgreSQL·u/logophobia·7 months ago
#SxVmyJK8
#query#parent_id#join#range#article
Reading 0:00
15s threshold

I have two partitioned tables, let's say a and b . They have UUIDv7 (timestamped) id columns. I am using a join-key structure, ensuring the foreign key relation doesn't require extra indexes. These are pretty high-volume event tables, where timestamp range queries and id based queries are the main form of read traffic.

CREATE TABLE public.a ( id uuid NOT NULL, CONSTRAINT "PK_a" PRIMARY KEY (id) ) PARTITION BY RANGE (id);

CREATE TABLE public.b ( parent_id uuid NOT NULL, object_number int2 NOT NULL, CONSTRAINT "PK_b" PRIMARY KEY (parent_id, object_number) ) PARTITION BY RANGE (parent_id);

The problem comes in here.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.