Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ub1td-0000LL-5U for pgsql-performance@arkaria.postgresql.org; Sat, 11 May 2013 04:59:11 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Ub1tc-0008KM-MK for pgsql-performance@arkaria.postgresql.org; Sat, 11 May 2013 04:59:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ub1tb-0008KG-LR for pgsql-performance@postgresql.org; Sat, 11 May 2013 04:58:59 +0000 Received: from [2404:130:0:10::40:2] (helo=mail.catalyst.net.nz) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ub1tW-00056U-Lx for pgsql-performance@postgresql.org; Sat, 11 May 2013 04:58:58 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.catalyst.net.nz (Postfix) with ESMTP id BE98733048 for ; Sat, 11 May 2013 16:58:48 +1200 (NZST) X-Virus-Scanned: Debian amavisd-new at catalyst.net.nz Received: from mail.catalyst.net.nz ([127.0.0.1]) by localhost (bertrand.catalyst.net.nz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xIhM-nVKrDXv for ; Sat, 11 May 2013 16:58:47 +1200 (NZST) Received: from [192.168.1.64] (122-60-64-230.jetstream.xtra.co.nz [122.60.64.230]) (Authenticated sender: mark.kirkwood) by mail.catalyst.net.nz (Postfix) with ESMTPSA id B809C32C08 for ; Sat, 11 May 2013 16:58:47 +1200 (NZST) Message-ID: <518DD007.4000006@catalyst.net.nz> Date: Sat, 11 May 2013 16:58:47 +1200 From: Mark Kirkwood User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130404 Thunderbird/17.0.5 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: In progress INSERT wrecks plans on table 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> <3833.1368192658@sss.pgh.pa.us> In-Reply-To: <3833.1368192658@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2404:130:0:10::40:2 (failed) X-Pg-Spam-Score: -1.1 (-) 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 On 11/05/13 01:30, Tom Lane wrote: > 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. Yeah - true, I was focusing on the particular type of query illustrated in the test case - pretty much entirely needing updated selectivity stats for a column, which wouldn't change unfortunately. Cheers Mark -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance