| From: | Richard Guo <guofenglinux(at)gmail(dot)com> |
|---|---|
| To: | Haowu Ge <gehaowu(at)bitmoe(dot)com> |
| Cc: | pgsql-bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Subject: | Re: GROUP BY ROLLUP queries on views trigger full table scans (index usage not optimized) |
| Date: | 2025-12-10 02:01:49 |
| Message-ID: | CAMbWs48j6BvDq9aCOM_gjgM6katSyrzpdgwoBBK1F7uD8pds4w@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
On Tue, Dec 9, 2025 at 5:54 PM Haowu Ge <gehaowu(at)bitmoe(dot)com> wrote:
> I built it via dpkg-buildpackage,
> but I'm unable to generate a proper installation package with the v2 patch
Hmm, I don't have much insight into the installation issue. I tested
the v2 patch on both v18 and master, and it fixes your query.
EXPLAIN (COSTS OFF)
SELECT material_id, AVG(unit_price) as avg_price
FROM materials_view
WHERE material_id = 'PI'
GROUP BY ROLLUP(material_id);
QUERY PLAN
--------------------------------------------------------
GroupAggregate
Group Key: materials.material_id
Group Key: ()
-> Index Scan using materials_pkey on materials
Index Cond: ((material_id)::text = 'PI'::text)
(5 rows)
Regarding back-patching, I believe this issue exists before v18, but
it seems that the change in v18 made it common enough to notice,
especially in queries with grouping sets. Given the lack of reports
for versions prior to v18, I'm inclined to back-patch this only to
v18.
Any thoughts?
- Richard
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Richard Guo | 2025-12-10 02:11:53 | Re: BUG #19007: Planner fails to choose partial index with spurious 'not null' |
| Previous Message | weijie JL | 2025-12-10 01:07:07 | Re: BUG #19348: Disk space error when running COPY after upgrading to PostgreSQL 17.7 |