I am attempting to use a DISTINCT ON query, but want to use the in
clause. I see the SkipScan piece in the explain analyze ONLY when using an =
, but fails to use SkipScan when using an in
.
Here’s the query that works with SkipScan, by just using equals: SbqY | explain.depesz.com
explain analyze select distinct on (prompt_template_id) prompt_template_id, time from events where prompt_template_id = '44138158-8b6b-4328-bd86-617f85268b53' order by 1, 2 desc;
And then here’s the query and plan for using an IN, but does not use the SkipScan: e2w5 | explain.depesz.com
explain analyze select distinct on (prompt_template_id) prompt_template_id, time from events where prompt_template_id in ('44138158-8b6b-4328-bd86-617f85268b53', '5ab0f9d1-a332-48a5-9771-3cb6e6759ba8') order by 1, 2 desc;