From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: Repair memory leakage while ANALYZE-ing complex index expression |
Date: | 2010-11-09 16:57:17 |
Message-ID: | E1PFrVV-0003bt-Ps@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Repair memory leakage while ANALYZE-ing complex index expressions.
The general design of memory management in Postgres is that intermediate
results computed by an expression are not freed until the end of the tuple
cycle. For expression indexes, ANALYZE has to re-evaluate each expression
for each of its sample rows, and it wasn't bothering to free intermediate
results until the end of processing of that index. This could lead to very
substantial leakage if the intermediate results were large, as in a recent
example from Jakub Ouhrabka. Fix by doing ResetExprContext for each sample
row. This necessitates adding a datumCopy step to ensure that the final
expression value isn't recycled too. Some quick testing suggests that this
change adds at worst about 10% to the time needed to analyze a table with
an expression index; which is annoying, but seems a tolerable price to pay
to avoid unexpected out-of-memory problems.
Back-patch to all supported branches.
Branch
------
REL8_3_STABLE
Details
-------
http://git.postgresql.org/gitweb?p=postgresql.git;a=commitdiff;h=55425d37214328bd3b45de99290dd8aa885c1a60
Modified Files
--------------
src/backend/commands/analyze.c | 23 ++++++++++++++++++++---
1 files changed, 20 insertions(+), 3 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2010-11-09 19:05:39 | pgsql: Improve pg_ctl's man page. |
Previous Message | Heikki Linnakangas | 2010-11-09 15:52:40 | pgsql: In rewriteheap.c (used by VACUUM FULL and CLUSTER), calculate th |