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 1pFgFR-0004ZQ-12 for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Jan 2023 18:54:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pFgFP-0003R1-Uh for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Jan 2023 18:54:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pFgFP-0003Og-LA for pgsql-hackers@lists.postgresql.org; Wed, 11 Jan 2023 18:54:51 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pFgFN-0007gM-3t for pgsql-hackers@postgresql.org; Wed, 11 Jan 2023 18:54:50 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 3346D32007E8; Wed, 11 Jan 2023 13:54:47 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 11 Jan 2023 13:54:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm3; t=1673463286; x=1673549686; bh=uQTIAc5hlG YF0lIqkCBRiqpXuRExJEpMtPii1d4YXCY=; b=eRvmrpH+/sFLbWBWPQAMkmVT9d S4V4uaDlmLooZ4Z/+Qk/LrfyQWxFnh4xCUO9YbRDH4WbWDs1L2yT6PdT9tboulz4 B+z8GyclxQ2xgapNBhaiEhgiX0WSOCpWvHOP+FK6FnRgkIsZWylThjagQxZMbTmt kH2/Lu3vr5fiAdxHsktpptTTOjtFWdzya9Lzitg36gDHRl3oll6EgZuWkRvZk6eo wAwqBj10lREeJqouvnhx/LbgZBYx4wPrUrU0wa1zym+FqBqU8grjrrRcYn9/zONl 0lHOMYIIvLmUmkoiEGn2rAJfvfembMoVwFURAc3uxybNoeOQqyi2trHwlO8w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1673463286; x=1673549686; bh=uQTIAc5hlGYF0lIqkCBRiqpXuREx JEpMtPii1d4YXCY=; b=h2eHxQ030PD5wIc68DgJQqxnNQFjPjA1cBf11LSZmYGX qhiWnAl1E+bZ8v0hBdviAeBt9Ko8D/wK115stvaj4DIlSrHDVju22yOY7SBJtboP SbpBP+kZEwxZSwA+vleGuH3exT9llAe9XEhLWpnWv57IjxUxs2zDQM+Z5TSpdMo4 5dKfxN8Mk19p753EGVJaTlvTGijP6oqhx8bsaMJYCwrbxm9EGM3R/4Iixk7Cz+LM bSenJVopKk25scF68fu3WI/2VbQZnVui0bCuteXGM5+4FB/WO5Sj3dhE8Fk1I2T1 42NQ6IQGzmSN+xX+egBkZuUTONT5DYm8ZI/0nDsA1Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrleeggdduudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomheptehnughr vghsucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrf grthhtvghrnhepvdfffeevhfetveffgeeiteefhfdtvdffjeevhfeuteegleduheetvedu ieettddunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh eprghnughrvghssegrnhgrrhgriigvlhdruggv X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 11 Jan 2023 13:54:46 -0500 (EST) Date: Wed, 11 Jan 2023 10:54:45 -0800 From: Andres Freund To: pgsql-hackers@postgresql.org, Peter Geoghegan , Robert Haas Cc: Melanie Plageman , David Rowley Subject: Re: Option to not use ringbuffer in VACUUM, using it in failsafe mode Message-ID: <20230111185445.rbs5tm32wstrc2yj@awork3.anarazel.de> References: <20230111182720.ejifsclfwymw2reb@awork3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230111182720.ejifsclfwymw2reb@awork3.anarazel.de> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2023-01-11 10:27:20 -0800, Andres Freund wrote: > On cloud hardware with higher fsync latency I've seen > 15x time differences > between using the ringbuffers and avoiding them by using pg_prewarm. A slightly edited version of what I've in the past to defeat the ringbuffers using pg_prewarm, as I think it might be useful for others: WITH what_rel AS ( SELECT 'copytest_0'::regclass AS vacuum_me ), what_to_prefetch AS ( SELECT vacuum_me, greatest(heap_blks_total - 1, 0) AS last_block, CASE WHEN phase = 'scanning heap' THEN heap_blks_scanned ELSE heap_blks_vacuumed END AS current_pos FROM what_rel, pg_stat_progress_vacuum WHERE relid = vacuum_me AND phase IN ('scanning heap', 'vacuuming heap') ) SELECT vacuum_me, current_pos, pg_prewarm(vacuum_me, 'buffer', 'main', current_pos, least(current_pos + 10000, last_block)) FROM what_to_prefetch \watch 0.1 Having this running in the background brings the s_b=128MB, ringbuffer enabled case down from 77797ms to 14838ms. Close to the version with the ringbuffer disabled. Unfortunately, afaik, that trick isn't currently possible for the index vacuum phase, as we don't yet expose the current scan position. And not every index might be as readily prefetchable as just prefetching the next 10k blocks from the current position. That's not too bad if your indexes are small, but unfortunately that's not always the case... Greetings, Andres Freund