Cache the results of ri_FetchConstraintInfo in a backend-local cache.

Tom Lane <tgl@sss.pgh.pa.us>

Commit: 45ba424f332a7eaa685a4e23f142a43114c65811
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2012-06-20T21:24:14Z
Releases: 9.3.0
Cache the results of ri_FetchConstraintInfo in a backend-local cache.

Extracting data from pg_constraint turned out to take as much as 10% of the
runtime in a bulk-update case where the foreign key column wasn't changing,
because we did it over again for each tuple.  Fix that by maintaining a
backend-local cache of the results.  This is really a pretty small patch,
but converting the trigger functions to work with pointers rather than
local struct variables requires a lot of mechanical changes.

Files

PathChange+/−
src/backend/utils/adt/ri_triggers.c modified +319 −229