Re: When Update balloons memory

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Klaudie Willis <Klaudie(dot)Willis(at)protonmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org, Peter Geoghegan <pg(at)bowt(dot)ie>
Subject: Re: When Update balloons memory
Date: 2021-12-14 15:58:55
Message-ID: 261065.1639497535@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-general

[ redirecting to pgsql-bugs ]

Klaudie Willis <Klaudie(dot)Willis(at)protonmail(dot)com> writes:
> Turns out the base case is simpler than I thought. Not involving partitions at all

> CREATE TABLE public.part_main (
> txid bigint,
> actiondate timestamp without time zone NOT NULL
> );

> insert into part_main
> select x, '2019-06-01'::timestamp + x%365 * interval '1 day'
> from generate_series(1, 30 * 1E6) as x;

> CREATE INDEX partindx ON public.part_main USING btree ((actiondate)::date); -- mem bug?
> -- mem runaway follows
> update part_main set txid = txid + 1;

ITYM "((actiondate::date))", but yeah, this leaks memory like there's
no tomorrow. I traced it to 9dc718bdf (Pass down "logically unchanged
index" hint), which has added a function index_unchanged_by_update()
that (a) looks fairly expensive, (b) leaks a copy of every expression
tree it examines, and (c) is invoked over again for each row, even
though AFAICS the answer shouldn't change across rows. This seems very
poorly thought through. Peter?

regards, tom lane

PS: personally I would have used pull_varnos() instead of reinventing
that wheel. But in any case the real problem is repeated invocation.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Klaudie Willis 2021-12-14 16:16:05 Re: When Update balloons memory
Previous Message Vincent Veyron 2021-12-14 15:58:35 Re: When Update balloons memory

Browse pgsql-general by date

  From Date Subject
Next Message Sanjay Minni 2021-12-14 16:00:42 Re: timestamp default current_timestamp not working
Previous Message Vincent Veyron 2021-12-14 15:58:35 Re: When Update balloons memory