pgsql: Free memory after building each statistics object

Поиск
Список
Период
Сортировка
От Tomas Vondra
Тема pgsql: Free memory after building each statistics object
Дата
Msg-id E1mTS5o-0005J9-6T@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Free memory after building each statistics object

Until now, all extended statistics on a given relation were built in the
same memory context, without resetting. Some of the memory was released
explicitly, but not all of it - for example memory allocated while
detoasting values is hard to free. This is how it worked since extended
statistics were introduced in PostgreSQL 10, but adding support for
extended stats on expressions made the issue somewhat worse as it
increases the number of statistics to build.

Fixed by adding a memory context which gets reset after building each
statistics object (all the statistics kinds included in it). Resetting
it after building each statistics kind would be even better, but it
would require more invasive changes and copying of results, making it
harder to backpatch.

Backpatch to PostgreSQL 10, where extended statistics were introduced.

Author: Justin Pryzby
Reported-by: Justin Pryzby
Reviewed-by: Tomas Vondra
Backpatch-through: 10
Discussion: https://www.postgresql.org/message-id/20210915200928.GP831%40telsasoft.com

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/3aac99068cd7abe9d6fbc8c0faa361d75f7d0bfc

Modified Files
--------------
src/backend/statistics/extended_stats.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tomas Vondra
Дата:
Сообщение: pgsql: Release memory allocated by dependency_degree
Следующее
От: Alexander Korotkov
Дата:
Сообщение: pgsql: Split macros from visibilitymap.h into a separate header