Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fC9OI-0004E1-IC for pgsql-general@arkaria.postgresql.org; Fri, 27 Apr 2018 19:50:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fC9OH-0005AH-5T for pgsql-general@arkaria.postgresql.org; Fri, 27 Apr 2018 19:50:45 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fC9OG-0005A8-Ts for pgsql-general@lists.postgresql.org; Fri, 27 Apr 2018 19:50:44 +0000 Received: from 23-25-19-49-static.hfc.comcastbusiness.net ([23.25.19.49] helo=jeeves.wrkhors.com) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fC9OD-0006De-Nz for pgsql-general@lists.postgresql.org; Fri, 27 Apr 2018 19:50:44 +0000 Received: from cannibal (cannibal.wrkhors.com [10.0.0.4]) by jeeves.wrkhors.com (Postfix) with ESMTP id 35308E851; Fri, 27 Apr 2018 15:00:50 -0500 (CDT) Date: Fri, 27 Apr 2018 14:50:41 -0500 From: Steven Lembark To: pgsql-general@lists.postgresql.org Cc: lembark@wrkhors.com Subject: Re: Long running INSERT+SELECT query Message-ID: <20180427145041.031abeda.lembark@wrkhors.com> In-Reply-To: <7808002c-089c-4556-52c7-0338fb864a51@gmail.com> References: <11ea9b74-243d-b275-be10-1004f51a4aa6@gmail.com> <39121e73-b04a-77c4-cb5f-55530e82f0d3@aklaver.com> <320a63d9-71b5-90d1-fd2c-9ed408ae1016@aklaver.com> <5893718d-4449-741f-671a-aea1ee654944@gmail.com> <20180427093027.6959987e@wrkhors.com> <7808002c-089c-4556-52c7-0338fb864a51@gmail.com> Organization: Workhorse Computing X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, 27 Apr 2018 19:38:15 +0300 Vitaliy Garnashevich wrote: > We're going to try using "SELECT 1 FROM table FOR KEY SHARE" for each of > the tables, which are referenced by results, before running the big > query. That should be up to a million of rows in total. It will probably > not cover the case when a record is INSERT'ed and then DELETE'd after > the calculation has begun, but such cases should be even more rare than > the DELETE's we're currently facing. Thing about using a couple of Materialized Views for the worst part of it. -- Steven Lembark 1505 National Ave Workhorse Computing Rockford, IL 61103 lembark@wrkhors.com +1 888 359 3508