Re: In progress INSERT wrecks plans on table

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Mark Kirkwood <mark(dot)kirkwood(at)catalyst(dot)net(dot)nz>
Cc: Vitalii Tymchyshyn <tivv00(at)gmail(dot)com>, pgsql-performance(at)postgresql(dot)org, Gavin Flower <gavinflower(at)archidevsys(dot)co(dot)nz>, Simon Riggs <simon(at)2ndquadrant(dot)com>
Subject: Re: In progress INSERT wrecks plans on table
Date: 2013-05-10 13:30:58
Message-ID: 3833.1368192658@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-performance

Mark Kirkwood <mark(dot)kirkwood(at)catalyst(dot)net(dot)nz> writes:
> Unfortunately a trigger will not really do the job - analyze ignores in
> progress rows (unless they were added by the current transaction), and
> then the changes made by analyze are not seen by any other sessions. So
> no changes to plans until the entire INSERT is complete and COMMIT
> happens (which could be a while - too long in our case).

I'm not sure I believe the thesis that plans won't change at all.
The planner will notice that the physical size of the table is growing.
That may not be enough, if the table-contents statistics are missing
or completely unreflective of reality, but it's something.

It is true that *already cached* plans won't change until after an
ANALYZE is done (the key point there being that ANALYZE sends out a
shared-inval message to force replanning of plans for the table).
Conceivably you could issue concurrent ANALYZEs occasionally while
the INSERT is running, not so much to update the stats --- because
they wouldn't --- as to force cached-plan invalidation.

regards, tom lane

--
Sent via pgsql-performance mailing list (pgsql-performance(at)postgresql(dot)org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2013-05-10 13:33:15 Re: Concurrent HOT Update interference
Previous Message Merlin Moncure 2013-05-10 13:28:24 Re: Concurrent HOT Update interference

Browse pgsql-performance by date

  From Date Subject
Next Message Robert Haas 2013-05-10 19:57:15 Re: PostgreSQL planner
Previous Message Mark Kirkwood 2013-05-10 12:51:20 Re: In progress INSERT wrecks plans on table