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:
@ -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
|
||||
|
Reference in New Issue
Block a user