Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ofudc-0002o5-9b for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Oct 2022 03:00:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ofudb-0005qf-2j for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Oct 2022 02:59:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ofuda-0005qS-Kp for pgsql-hackers@lists.postgresql.org; Wed, 05 Oct 2022 02:59:58 +0000 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ofudW-00007J-67 for pgsql-hackers@lists.postgresql.org; Wed, 05 Oct 2022 02:59:58 +0000 Received: by mail-pf1-x433.google.com with SMTP id v186so14750543pfv.11 for ; Tue, 04 Oct 2022 19:59:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20210112.gappssmtp.com; s=20210112; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date; bh=2AHhaJEJBP4lpwpSWd0QKpHX3osWZYXkiHjyr0A8lA8=; b=EfZHyenohck1/spOGMK2g4DT3iOP9g6n5Swch/DWfosRCB+tl0NudyToeWvBOibaC9 zNEusyAxqDmWqwsffab4F21epEYQUowGW2n6blAu6Evy1HrY7G5a+0igxoqfLQ+UuXrA U00LzcY4h375EM8Y0NRAadQPVCWx9lnHWXXMKbDw2hU2W7Cah2ldHExFXjOpOgNTUfYt sTvMX5iqubg4KtUma7lazuOSS70HpqNe6rprxV4GA2gtNJTvvLid6mZIePZ/eBqBeDWG jqcWvDcDUqm0R8rrroz7S78U/xv7fgMzFbQbh/FxcQM5NW3Ipw+Juv2/OYqTRoAnZ794 QXRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date; bh=2AHhaJEJBP4lpwpSWd0QKpHX3osWZYXkiHjyr0A8lA8=; b=kufBmYUdhkQ3UCmsrwEx4F5rJjD+ErhVRZRGE5z6fjiDQo+c14ldez7oALjPngSOz4 8wOouNS3IPtc7DPqTmJEN3s+PJNDvkhNT7S8d1A6U4zYichi+GEbbx1LbF8nGUJCnrD0 3+nXEZ65RGxsxt4OqQNoVycuOEpkL0GTjoqaBU9R8CAkRK8ju4IozhovqDoayoTWx0op XOcAtX/ATI8DaVxQFCSittLt3H/p7YWEBFNKRClrHsWallJg1jgbiGlAZFWOeWtytlBE sBzUBob/UpuA0qo6Q6Q9YI1sTlIorBgNv2HQ0UzyTlP6E5I8TTPT+UchJax3SqUNooEJ nc/A== X-Gm-Message-State: ACrzQf2BU/AJK7gLJPC4pf8pOPjMN4lLWN1gBhwpsCnS+QwdKLE+7zGB RlIpD9bef1QjDDI00QhlkPLNOrC2OF3sRg== X-Google-Smtp-Source: AMsMyM6FlYGV0ozcIxMGgWMftknPi9orHo36dDJO2db+pk1JHaKuHWYfy0ERP72k6bYkkj4ymIFfWQ== X-Received: by 2002:a62:2983:0:b0:54e:7cd5:adb3 with SMTP id p125-20020a622983000000b0054e7cd5adb3mr30259595pfp.38.1664938791603; Tue, 04 Oct 2022 19:59:51 -0700 (PDT) Received: from [172.28.3.178] ([96.68.148.225]) by smtp.gmail.com with ESMTPSA id p5-20020a17090a348500b0020aebb75b6esm281690pjb.19.2022.10.04.19.59.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Oct 2022 19:59:50 -0700 (PDT) Message-ID: <34fbcae89ed533bb4a47b0be949b0115bb83446c.camel@j-davis.com> Subject: Re: New strategies for freezing, advancing relfrozenxid early From: Jeff Davis To: Peter Geoghegan Cc: PostgreSQL Hackers Date: Tue, 04 Oct 2022 19:59:49 -0700 In-Reply-To: References: <1892cc797f86924e31f00fd3c703ca464936c65e.camel@j-davis.com> <424877f4840495235b9be5cacc65a2b84d000566.camel@j-davis.com> <9bc85fb435df6f5fc2ececc00c0a086d41b755b4.camel@j-davis.com> <78aecdaa345ea8cb1554ff2dbc08eb0e2262130a.camel@j-davis.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.1-0ubuntu1 MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 2022-10-04 at 11:09 -0700, Peter Geoghegan wrote: > So a simplistic threshold > (combined with dynamic per-page decisions about freezing) should be > enough to avoid most of the downside of eager freezing. ... > I want to keep > the cost as low as possible (often "negative cost" relative to > Postgres 15), but overall I am consciously making a trade-off. There > are downsides. I am fine with that, but I'd like us all to understand what the downsides are. If I understand correctly: 1. Eager freezing (meaning to freeze at the same time as setting all- visible) causes a modest amount of WAL traffic, hopefully before the next checkpoint so we can avoid FPIs. Lazy freezing (meaning set all- visible but don't freeze) defers the work, and it might never need to be done; but if it does, it can cause spikes at unfortunate times and is more likely to generate more FPIs. 2. You're trying to mitigate the downsides of eager freezing by: a. when freezing a tuple, eagerly freeze other tuples on that page b. optimize WAL freeze records 3. You're trying to capture the trade-off in #1 by using the table size as a proxy. Deferred work is only really a problem for big tables, so that's where you use eager freezing. But maybe we can just always use eager freezing?: a. You're mitigating the WAL work for freezing. b. A lot of people run with checksums on, meaning that setting the all-visible bit requires WAL work anyway, and often FPIs. c. All-visible is conceptually similar to freezing, but less important, and it feels more and more like the design concept of all- visible isn't carrying its weight. d. (tangent) I had an old patch[1] that actually removed PD_ALL_VISIBLE (the page bit, not the VM bit), which was rejected, but perhaps its time has come? Regards, Jeff Davis [1] https://www.postgresql.org/message-id/1353551097.11440.128.camel%40sussancw= s0025