From: | Matheus Alcantara <matheusssilv97(at)gmail(dot)com> |
---|---|
To: | David Rowley <dgrowleyml(at)gmail(dot)com>, Vik Fearing <vik(at)postgresfriends(dot)org> |
Cc: | Marcos Pegoraro <marcos(at)f10(dot)com(dot)br>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Peter Eisentraut <peter(at)eisentraut(dot)org> |
Subject: | Re: Proposal: QUALIFY clause |
Date: | 2025-07-29 00:10:56 |
Message-ID: | CAFY6G8ddUU_v+67CH6VYxndJvihkD7hECwfyV1wZApc4DYSpqg@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 22/07/25 19:32, David Rowley wrote:
> Looking at the latest patch I see that pushdowns don't work:
>
> # explain select row_number() over (order by oid) rb from pg_Class
> qualify row_number () over (order by oid)=1;
>
> # explain (analyze, costs off, buffers off, summary off) select
> row_number() over (order by oid) rb from pg_Class qualify row_number
> () over (order by oid)=1;
>
> WindowAgg (actual time=0.041..0.273 rows=1.00 loops=1)
> Window: w1 AS (ORDER BY oid ROWS UNBOUNDED PRECEDING)
> Filter: (row_number() OVER w1 = 1)
> Rows Removed by Filter: 415
> Storage: Memory Maximum Storage: 17kB
> -> Index Only Scan using pg_class_oid_index on pg_class (actual
> time=0.032..0.125 rows=416.00 loops=1)
> Heap Fetches: 0
> Index Searches: 1
>
> Whereas, with a subquery we get:
>
> # explain (analyze, costs off, buffers off, summary off)
> select * from (select row_number() over (order by oid) rn from
> pg_class) r where r.rn=1;
>
> Subquery Scan on r (actual time=0.042..0.044 rows=1.00 loops=1)
> Filter: (r.rn = 1)
> -> WindowAgg (actual time=0.041..0.043 rows=1.00 loops=1)
> Window: w1 AS (ORDER BY pg_class.oid ROWS UNBOUNDED PRECEDING)
> Run Condition: (row_number() OVER w1 <= 1)
> Storage: Memory Maximum Storage: 17kB
> -> Index Only Scan using pg_class_oid_index on pg_class
> (actual time=0.030..0.031 rows=2.00 loops=1)
> Heap Fetches: 0
> Index Searches: 1
>
By "pushdowns" you mean missing the Run Conditions on the QUALIFY
example? IIUC the Run Condition is only created if it's a subquery. I've
checked this on set_rel_size() -> set_subquery_pathlist() ->
check_and_push_window_quals().
> Also, this seems busted:
>
> # select row_number() over (order by oid) rn from pg_class qualify rn=1;
> server closed the connection unexpectedly
>
Thanks for testing! I'm working on this and some other issues.
--
Matheus Alcantara
From | Date | Subject | |
---|---|---|---|
Next Message | Daniel Bauman | 2025-07-29 00:27:54 | Re: Doc update proposal for the note on log_statement in the runtime config for logging page |
Previous Message | David G. Johnston | 2025-07-28 23:53:20 | Re: Doc update proposal for the note on log_statement in the runtime config for logging page |