<html><head></head><body style="zoom: 0%;"><div dir="auto">Rewrite to have a CTE with the area calculations and join to the table.<br><br></div>
<div dir="auto"><!-- tmjah_g_1299s -->Get <!-- tmjah_g_1299e --><a href="http://www.bluemail.me/r?b=16117"><!-- tmjah_g_1299s -->BlueMail for Android<!-- tmjah_g_1299e --></a><!-- tmjah_g_1299s --> <!-- tmjah_g_1299e --></div>
<div class="gmail_quote" >On Sep 27, 2020, at 2:29 AM, Marco Boeringa <<a href="mailto:marco@boeringa.demon.nl" target="_blank">marco@boeringa.demon.nl</a>> wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="blue">Hi all,<br><br>This may be an irrelevant basic question, but I just cannot find a clear <br>answer to this, there is no documentation in the PostgreSQL docs for <br>UPDATE about this:<br><br>In case I set multiple columns using some PostGIS function that clearly <br>has a (considerable) cost associated with it, and the value of the first <br>column being set is also needed to set the second column, does <br>PostgreSQL automatically optimize this and re-use the value already <br>calculated for column 1 to set column 2's value, or is each column's SET <br>statement treated as independent entity?<br><br>E.g. let's say I want to calculate both area, and the division of area <br>and perimeter, like:<br><br>UPDATE <MY_TABLE> SET area = ST_Area(<GEOMETRY_COLUMN>), area_perimeter <br>= ST_Area(<GEOMETRY_COLUMN>) / ST_Perimeter(<GEOMETRY_COLUMN>)<br><br>Will PostgreSQL only process 'ST_Area(<GEOMETRY_COLUMN>)' once in this <br>case, thus saving CPU load, or do I need to rewrite the SQL statement <br>somehow to achieve that?<br><br>Marco<br><br><hr><br>postgis-users mailing list<br>postgis-users@lists.osgeo.org<br><a href="https://lists.osgeo.org/mailman/listinfo/postgis-users">https://lists.osgeo.org/mailman/listinfo/postgis-users</a></pre></blockquote></div></body></html>