aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/statistics/extended_stats.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c
index 0c80e55d107..4c19336b293 100644
--- a/src/backend/statistics/extended_stats.c
+++ b/src/backend/statistics/extended_stats.c
@@ -97,14 +97,15 @@ BuildRelationExtStatistics(Relation onerel, double totalrows,
MemoryContext oldcxt;
int64 ext_cnt;
+ pg_stext = table_open(StatisticExtRelationId, RowExclusiveLock);
+ stats = fetch_statentries_for_relation(pg_stext, RelationGetRelid(onerel));
+
+ /* memory context for building each statistics object */
cxt = AllocSetContextCreate(CurrentMemoryContext,
"BuildRelationExtStatistics",
ALLOCSET_DEFAULT_SIZES);
oldcxt = MemoryContextSwitchTo(cxt);
- pg_stext = table_open(StatisticExtRelationId, RowExclusiveLock);
- stats = fetch_statentries_for_relation(pg_stext, RelationGetRelid(onerel));
-
/* report this phase */
if (stats != NIL)
{
@@ -189,12 +190,17 @@ BuildRelationExtStatistics(Relation onerel, double totalrows,
/* for reporting progress */
pgstat_progress_update_param(PROGRESS_ANALYZE_EXT_STATS_COMPUTED,
++ext_cnt);
- }
- table_close(pg_stext, RowExclusiveLock);
+ /* free the data used for building this statistics object */
+ MemoryContextReset(cxt);
+ }
MemoryContextSwitchTo(oldcxt);
MemoryContextDelete(cxt);
+
+ list_free(stats);
+
+ table_close(pg_stext, RowExclusiveLock);
}
/*