From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
---|---|
To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Cc: | tim3sp(at)gmail(dot)com |
Subject: | BUG #17862: Overall query cost ignores window function |
Date: | 2023-03-22 17:42:03 |
Message-ID: | 17862-1ab8f74b0f7b0611@postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 17862
Logged by: Tim Palmer
Email address: tim3sp(at)gmail(dot)com
PostgreSQL version: 15.2
Operating system: Debian
Description:
This query needs to read all of large_table to count the number of rows,
despite the LIMIT clause:
SELECT large_table.*, count(*) OVER ()
FROM generate_series(1, 1000000000000) large_table
LIMIT 10
I would have expected a query plan something like this, with a large overall
cost:
Limit (cost=0.00..22500000000.00 rows=10 width=16)
-> WindowAgg (cost=0.00..22500000000.00 rows=1000000000000 width=16)
-> Function Scan on generate_series large_table
(cost=0.00..10000000000.00 rows=1000000000000 width=8)
But I actually get this query plan, with a cost of 0.23:
Limit (cost=0.00..0.23 rows=10 width=16)
-> WindowAgg (cost=0.00..22500000000.00 rows=1000000000000 width=16)
-> Function Scan on generate_series large_table
(cost=0.00..10000000000.00 rows=1000000000000 width=8)
I believe this (on a more complicated query) is affecting the plan chosen by
the optimizer.
From | Date | Subject | |
---|---|---|---|
Next Message | David Rowley | 2023-03-22 21:03:11 | Re: BUG #17862: Overall query cost ignores window function |
Previous Message | PG Bug reporting form | 2023-03-22 15:50:28 | BUG #17861: Disappearance of packages in repo for rhel-8 |