Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UanPr-0001MT-0z for pgsql-performance@arkaria.postgresql.org; Fri, 10 May 2013 13:31:19 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UanPq-0001UF-Fo for pgsql-performance@arkaria.postgresql.org; Fri, 10 May 2013 13:31:18 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UanPp-0001TZ-F8 for pgsql-performance@postgresql.org; Fri, 10 May 2013 13:31:17 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UanPi-00075a-5M for pgsql-performance@postgresql.org; Fri, 10 May 2013 13:31:17 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id r4ADUw6M003834; Fri, 10 May 2013 09:30:58 -0400 (EDT) From: Tom Lane To: Mark Kirkwood cc: Vitalii Tymchyshyn , pgsql-performance@postgresql.org, Gavin Flower , Simon Riggs Subject: Re: In progress INSERT wrecks plans on table In-reply-to: <518CED48.1030706@catalyst.net.nz> References: <5179E77B.7050601@catalyst.net.nz> <5179ECC5.2010206@archidevsys.co.nz> <5179F259.3010509@catalyst.net.nz> <5179F5C6.8070702@archidevsys.co.nz> <5180E3C8.3010201@catalyst.net.nz> <2121.1367417215@sss.pgh.pa.us> <5181B80D.70404@catalyst.net.nz> <916bff05a5ab130c76d7835abbaf7762.squirrel@mail.catalyst.net.nz> <51870CB6.6090404@catalyst.net.nz> <51889FF4.7000306@catalyst.net.nz> <518CED48.1030706@catalyst.net.nz> Comments: In-reply-to Mark Kirkwood message dated "Sat, 11 May 2013 00:51:20 +1200" Date: Fri, 10 May 2013 09:30:58 -0400 Message-ID: <3833.1368192658@sss.pgh.pa.us> X-Pg-Spam-Score: -3.2 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Mark Kirkwood 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@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance