From: | David Rowley <dgrowleyml(at)gmail(dot)com> |
---|---|
To: | Marco Boeringa <marco(at)boeringa(dot)demon(dot)nl> |
Cc: | Andres Freund <andres(at)anarazel(dot)de>, pgsql-bugs(at)lists(dot)postgresql(dot)org, Thom Brown <thom(at)linux(dot)com> |
Subject: | Re: Potential "AIO / io workers" inter-worker locking issue in PG18? |
Date: | 2025-10-20 19:09:30 |
Message-ID: | CAApHDvrDwDyRGsj7qBk0M5PN0THWh2pf+dcVPFmcqW-vidcbdw@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Tue, 21 Oct 2025 at 03:42, Marco Boeringa <marco(at)boeringa(dot)demon(dot)nl> wrote:
> Looking through the 'auto_explain' output of the bad query plan, I
> noticed the below included clause as generated by the planner. In the
> context of what I actually wrote above about the desire to not run
> expensive function calls like ST_Area multiple times, do I understand it
> correctly from the 'auto_explain' output excerpt that PostgreSQL, by
> removing the self join, actually *does* run the ST_Area and ST_Perimeter
> multiple times? Is this how I need to interpret this part of the
> 'auto_explain' output? If there is no caching of the function result,
> this could be expensive as well.
So you basically have something like:
UPDATE t t1 SET col1 = t2.a1, col2 = t2.a2
FROM (SELECT unique_col, f1(col3) as a1, f2(col4) as a2 FROM t) AS t2
WHERE t1.unique_col = t2.unique_col
AND <other filter clauses>
Assuming here that unique_col has a UNIQUE or PK constraint. The self
join basically amounts to wasted effort. There is no function result
caching anywhere. Looking at the EXPLAIN output, it seems those
functions are executed once per row that's output from the join and
just below the "Update" node and they're executed 8 times. That won't
change if you get rid of the self join.
David
From | Date | Subject | |
---|---|---|---|
Next Message | David Rowley | 2025-10-20 19:27:47 | Re: Segfault in RI UPDATE CASCADE on partitioned tables with LIKE+ATTACH child (attnum drift) |
Previous Message | Peter Geoghegan | 2025-10-20 17:18:12 | Re: PG17.6 wal apply bug (SIGSEGV) |