pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Klaudie Willis <Klaudie.Willis@protonmail.com>
Cc: pgsql-bugs@lists.postgresql.org, Peter Geoghegan <pg@bowt.ie>
Subject: Re: When Update balloons memory
Date: Tue, 14 Dec 2021 10:58:55 -0500
Message-ID: <261065.1639497535@sss.pgh.pa.us> (raw)
In-Reply-To: <lviv_r7tA44gnx3rRU8VYdseWJLx-AzQCbsgdyz2-1Lse9ZmqDeLnzfDkBTut26kxlPZ8FX36TiKmCtXi5gAfhI-JVu-2n8fu7Dcta0Y3Ek=@protonmail.com>
References: <wJYzIcLjhFnsbCK8sy4lZZAojx7m04FwjsGF4WbrKj0gj2wLpaycQSEN1mtBUlhSAQGRvEdxZTwWRNV39UevSNWg8-h-tvWAL61pV4IuhW4=@protonmail.com>
	<3484560.1638889073@sss.pgh.pa.us>
	<YAjwxLJ1p4do7V4OkzpgwXrfV-fywioBsfvFaHnuY1Hbe-NjM0tsaCpJ_-KXwvFKF2YsQzQLCnFFFlMnyzd6TJ9UcXnQpcZfdZ1ZDcCqXIE=@protonmail.com>
	<189763.1639437451@sss.pgh.pa.us>
	<lviv_r7tA44gnx3rRU8VYdseWJLx-AzQCbsgdyz2-1Lse9ZmqDeLnzfDkBTut26kxlPZ8FX36TiKmCtXi5gAfhI-JVu-2n8fu7Dcta0Y3Ek=@protonmail.com>

[ redirecting to pgsql-bugs ]

Klaudie Willis <Klaudie.Willis@protonmail.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.





view thread (22+ messages)  latest in thread

Message-ID: <261065.1639497535@sss.pgh.pa.us>
Permalink:  ../261065.1639497535@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/261065.1639497535@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, Klaudie.Willis@protonmail.com, pg@bowt.ie
  Subject: Re: When Update balloons memory
  In-Reply-To: <261065.1639497535@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox