Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hCG66-00079E-33 for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Apr 2019 04:04:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hCG64-0005D5-A3 for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Apr 2019 04:04:56 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hCG63-0005Cy-UL for pgsql-hackers@lists.postgresql.org; Fri, 05 Apr 2019 04:04:56 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hCG60-0005Vi-VD for pgsql-hackers@postgresql.org; Fri, 05 Apr 2019 04:04:54 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 41A312215E; Fri, 5 Apr 2019 00:04:51 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Fri, 05 Apr 2019 00:04:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=7dh8n6dGyNcvdIflthzekrHnzHu W3Vx/sscFJA51A1M=; b=KdXsJhlTQ9S5KYN+BZijXAvAi6Wdf8vS5XeQMhKZUq6 2/e917IM4Gw96Yx7UIkhMOAmjW8yWb+3d+X4TxSUpr5vLHOdAUdDcAXbkMufqjEz XVLuzZPDoNlSGSFRlG1DHF8367W5YRSxI27iNw17su5Z5T93P9Ims+JwXReVcLy2 lYUwxC2HeC+x1Z8APvypKuo+flNTVN3jH9unSE0W5PkVS97/maTB/71bL3qg1auI pQHrA1nLWZqpq2x5cZUpZOR981W+QuukM0hLxpzHakQvVG+ZLVrKHJWk2dGbmFKu bQ6wps9iScT6hsB3aj9eIHkLR2aoXgCvLrBwskC74Gw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=7dh8n6 dGyNcvdIflthzekrHnzHuW3Vx/sscFJA51A1M=; b=v+7eyMMCnpa3IgEgQNnrXN iBEMB45DbzTS95ZJ4uTiq63EJPKKUrRAHa70Cnuo+uckIb4jQ3k3RKXOkQqawKd5 /q2rubXSNBWq9MQr145Q0tpHHHDyzA25k7DePt6DB+SGb1GEnM7Xk1LGxcCVtKov xjRgUWtN1lLskBuyy/WL2L6V+vwN4DMMubk2uBg20pLlvZKbhg29qpN9JpazDtFI d526fq8yqjE6ok3yoJptupU4T/X+J1aEwsqKOwVPwC3eTu2w6QcCYnh54S0814+A SuqjGvBLiiO6qBV/tdumg/iZaDq/aD0TmSvJMlfSThPsYeyCLSKl8K4/bqp4UAbw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrtdeigdejieculddtuddrgedutddrtddtmd cutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpeffhffvuffkfhggtggujgesthdtredttddtvden ucfhrhhomheptehnughrvghsucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivg hlrdguvgeqnecukfhppeelkedrvddutddrudegtddrudejudenucfrrghrrghmpehmrghi lhhfrhhomheprghnughrvghssegrnhgrrhgriigvlhdruggvnecuvehluhhsthgvrhfuih iivgeptd X-ME-Proxy: Received: from intern.anarazel.de (c-98-210-140-171.hsd1.ca.comcast.net [98.210.140.171]) by mail.messagingengine.com (Postfix) with ESMTPA id 780161031A; Fri, 5 Apr 2019 00:04:50 -0400 (EDT) Date: Thu, 4 Apr 2019 21:04:49 -0700 From: Andres Freund To: Tom Lane Cc: Alvaro Herrera , Pavan Deolasee , Masahiko Sawada , pgsql-hackers , Jeff Janes , Simon Riggs , Tomas Vondra Subject: Re: COPY FREEZE and setting PD_ALL_VISIBLE/visibility map bits Message-ID: <20190405040449.5yltddxmlxombova@alap3.anarazel.de> References: <20190404214520.7rfufsubxekodypr@alap3.anarazel.de> <20190405030604.GA3360@alvherre.pgsql> <20190405033537.vklegbflesm2c7m3@alap3.anarazel.de> <959.1554436678@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <959.1554436678@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 2019-04-04 23:57:58 -0400, Tom Lane wrote: > Andres Freund writes: > > I think the right approach would be to do all of this in heap_insert and > > heap_multi_insert. Whenever starting to work on a page, if INSERT_FROZEN > > is specified, remember whether it is either currently empty, or is > > already marked as all-visible. If previously empty, mark it as all > > visible at the end. If already all visible, there's no need to change > > that. If not yet all-visible, no need to do anything, since it can't > > have been inserted with COPY FREEZE. Do you see any problem doing it > > that way? > > Do we want to add overhead to these hot-spot routines for this purpose? For heap_multi_insert I can't see it being a problem - it's only used from copy.c, and the cost should be "smeared" over many tuples. I'd assume that compared with locking a page, WAL logging, etc, it'd not even meaningfully show up for heap_insert. Especially because we already have codepaths for options & HEAP_INSERT_FROZEN in heap_prepare_insert(), and I'd assume those could be combined. I think we should measure it, but I don't think that one or two additional, very well predictd, branches are going to be measurable in in those routines. The patch, as implemented, has modifications in RelationGetBufferForTuple(), that seems like they'd be more expensive. Greetings, Andres Freund