Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZHcF3-0005E7-EJ for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Jul 2015 18:26:13 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZHcF3-0001SG-0e for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Jul 2015 18:26:13 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZHcDl-0008ML-C7 for pgsql-hackers@postgresql.org; Tue, 21 Jul 2015 18:24:53 +0000 Received: from mxout.myoutlookonline.com ([74.201.97.202]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZHcDi-0002bP-KY for pgsql-hackers@postgresql.org; Tue, 21 Jul 2015 18:24:52 +0000 Received: from mxout.myoutlookonline.com (localhost [127.0.0.1]) by mxout.myoutlookonline.com (Postfix) with ESMTP id ADFBB64A5C80; Tue, 21 Jul 2015 14:18:56 -0400 (EDT) X-Virus-Scanned: by SpamTitan at myoutlookonline.com Received: from mxout.myoutlookonline.com (localhost [127.0.0.1]) by mxout.myoutlookonline.com (Postfix) with ESMTP id 8F58F64A633B; Tue, 21 Jul 2015 14:18:55 -0400 (EDT) Received: from S10HUB004.SH10.lan (unknown [10.110.2.1]) by mxout.myoutlookonline.com (Postfix) with ESMTP id 7328064A6355; Tue, 21 Jul 2015 14:18:55 -0400 (EDT) Received: from S10HUBR001.SH10.lan (10.110.133.100) by S10HUB004.SH10.lan (10.110.133.14) with Microsoft SMTP Server (TLS) id 14.1.421.2; Tue, 21 Jul 2015 14:24:47 -0400 Received: from tcook2.blackducksoftware.com (208.177.254.126) by mail10.myoutlookonline.com (10.110.133.100) with Microsoft SMTP Server id 14.1.438.0; Tue, 21 Jul 2015 14:24:47 -0400 Message-ID: <55AE8E6F.7030504@blackducksoftware.com> Date: Tue, 21 Jul 2015 14:24:47 -0400 From: "Todd A. Cook" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Tom Lane CC: Andres Freund , Fujii Masao , Martijn van Oosterhout , PostgreSQL-development Subject: Re: WAL logging problem in 9.4.3? References: <28320.1435935120@sss.pgh.pa.us> <20150703164931.GI3291@awork2.anarazel.de> <20150703170229.GJ3291@awork2.anarazel.de> <20150703172605.GM3291@awork2.anarazel.de> <27532.1436195680@sss.pgh.pa.us> <20150706152123.GK8902@alap3.anarazel.de> <28415.1436197794@sss.pgh.pa.us> <20150709182315.GG10242@alap3.anarazel.de> <29916.1436483171@sss.pgh.pa.us> In-Reply-To: <29916.1436483171@sss.pgh.pa.us> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [208.177.254.126] X-MS-Exchange-Transport-Rules-Loop: 0 X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Hi, This thread seemed to trail off without a resolution. Was anything done? (See more below.) On 07/09/15 19:06, Tom Lane wrote: > Andres Freund writes: >> On 2015-07-06 11:49:54 -0400, Tom Lane wrote: >>> Rather than reverting cab9a0656c36739f, which would re-introduce a >>> different performance problem, perhaps we could have COPY create a new >>> relfilenode when it does this. That should be safe if the table was >>> previously empty. > >> I'm not convinced that cab9a0656c36739f needs to survive in that >> form. To me only allowing one COPY to benefit from the wal_level = >> minimal optimization has a significantly higher cost than >> cab9a0656c36739f. > > What evidence have you got to base that value judgement on? > > cab9a0656c36739f was based on an actual user complaint, so we have good > evidence that there are people out there who care about the cost of > truncating a table many times in one transaction. I'm the complainer mentioned in the cab9a0656c36739f commit message. :) FWIW, we use a temp table to split a join across 4 largish tables (10^8 rows or more each) and 2 small tables (10^6 rows each). We write the results of joining the 2 largest tables into the temp table, and then join that to the other 4. This gave significant performance benefits because the planner would know the exact row count of the 2-way join heading into the 4-way join. After commit cab9a0656c36739f, we got another noticeable performance improvement (I did timings before and after, but I can't seem to put my hands on the numbers right now). We do millions of these queries every day in batches. Each batch reuses a single temp table (truncating it before each pair of joins) so as to reduce the churn in the system catalogs. In case it matters, the temp table is created with ON COMMIT DROP. This was (and still is) done on 9.2.x. HTH. -- todd cook -- tcook@blackducksoftware.com > On the other hand, > I know of no evidence that anyone's depending on multiple sequential > COPYs, nor intermixed COPY and INSERT, to be fast. The original argument > for having this COPY optimization at all was to make restoring pg_dump > scripts in a single transaction fast; and that use-case doesn't care > about anything but a single COPY into a virgin table. > > I think you're worrying about exactly the wrong case. > >> My tentative guess is that the best course is to >> a) Make heap_truncate_one_rel() create a new relfeilnode. That fixes the >> truncation replay issue. >> b) Force new pages to be used when using the heap_sync mode in >> COPY. That avoids the INIT danger you found. It seems rather >> reasonable to avoid using pages that have already been the target of >> WAL logging here in general. > > And what reason is there to think that this would fix all the problems? > We know of those two, but we've not exactly looked hard for other cases. > Again, the only known field usage for the COPY optimization is the pg_dump > scenario; were that not so, we'd have noticed the problem long since. > So I don't have any faith that this is a well-tested area. > > regards, tom lane > > -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers