This is my table:
CREATE TABLE IF NOT EXISTS public.ob_samples_sc5555 (
stamp timestamp(6) with time zone NOT NULL,
oblvl smallint NOT NULL,
olots integer NOT NULL,
CONSTRAINT prk_ob_samples_sc5555 PRIMARY KEY (stamp, oblvl)
);
This is my query:
delete from ob_samples_sc5555
where stamp <= to_timestamp('2023-12-29 15:00:00', 'YYYY-MM-DD HH24:MI:SS');
Explain:
Finalize Aggregate (cost=10106164.53..10106164.54 rows=1 width=8)
-> Gather (cost=10106163.59..10106164.50 rows=9 width=8) Workers Planned: 9 -> Partial Aggregate (cost=10105163.59..10105163.60 rows=1 width=8) -> Parallel Seq Scan on ob_samples_sc5555 (cost=0.00..9917330.49 rows=75133240 width=0) Filter: (stamp <= to_timestamp('2023-12-29 15:00:00'::text, 'YYYY-MM-DD HH24:MI:SS'::text))JIT: Functions: 6 Options: Inlining true, Optimization true, Expressions true, Deforming true
Why does PG13 use a seq scan instead of primary key, while the column stamp is the first column of the PK?