1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-30 21:42:05 +03:00

Optimize update of tables with generated columns

When updating a table row with generated columns, only recompute those
generated columns whose base columns have changed in this update and
keep the rest unchanged.  This can result in a significant performance
benefit.  The required information was already kept in
RangeTblEntry.extraUpdatedCols; we just have to make use of it.

Reviewed-by: Pavel Stehule <pavel.stehule@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/b05e781a-fa16-6b52-6738-761181204567@2ndquadrant.com
This commit is contained in:
Peter Eisentraut
2020-02-17 15:19:58 +01:00
parent ad3ae64770
commit c6679e4fca
5 changed files with 38 additions and 10 deletions

View File

@ -3222,7 +3222,7 @@ CopyFrom(CopyState cstate)
/* Compute stored generated columns */
if (resultRelInfo->ri_RelationDesc->rd_att->constr &&
resultRelInfo->ri_RelationDesc->rd_att->constr->has_generated_stored)
ExecComputeStoredGenerated(estate, myslot);
ExecComputeStoredGenerated(estate, myslot, CMD_INSERT);
/*
* If the target is a plain table, check the constraints of