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)
{
/* 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);
}
/*