Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1umeoD-001X3M-F4 for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Aug 2025 20:44:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1umeoB-009g5C-0f for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Aug 2025 20:44:23 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1umeoA-009g53-4Y for pgsql-hackers@lists.postgresql.org; Thu, 14 Aug 2025 20:44:22 +0000 Received: from fhigh-b1-smtp.messagingengine.com ([202.12.124.152]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1umeo6-000n6F-2U for pgsql-hackers@lists.postgresql.org; Thu, 14 Aug 2025 20:44:21 +0000 Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.stl.internal (Postfix) with ESMTP id 147AF7A0116; Thu, 14 Aug 2025 16:44:16 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Thu, 14 Aug 2025 16:44:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1755204255; x=1755290655; bh=HvTEQmbJ9RUziBD8lnfhyTp2BrXoOFaNUZyx45HcujU=; b= U5TuSjmib4JRAbgvUYsHMOiSKrwZ8j8NrDU74JnuerAYoZRTa3iAUqSzl9LHITvH 6e2EVUDrSXlBOYUshb+62J76Wpbx0gfNykYBJUp9qmEp2pYcV6hJ5vXAOqzO02Eu zTacl/juMXCoVIq3G9vYvxVb5JwcRWHPAsZYgwwYl/ILbGNAQWqA318FAbAVmv1U ePJKFs/+IFqSVgNFVO4aUCrfaiEO/qZhLYY6d3Z4Vn50zKlrJY50BfGD1yxakRKS zivtdTbXt+8lEUaDb12yghh5L5f4JiaNtA0bINRp0hvzWVGEg7QRx7wZzGDwChb9 N+GRitU74K683wq8tLscyg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1755204255; x= 1755290655; bh=HvTEQmbJ9RUziBD8lnfhyTp2BrXoOFaNUZyx45HcujU=; b=D 0/3DQxLJy3hcfc7f2WGI+FOtpIzcvYa3uZrsG9c41F0pwV4udwBL8W1weh1YNQTQ 9vFoM0bWtfoqs0va8pHI5WigPeGn8sWAGCp1TTYBfx5qo75LvKeIRbmJFAVVSF7s 4A24QOQTi7G+GgGoyJKQ8qgDpPJhopynBhGnu5FAAcz9fUvMC4Eq5ZQ6VgXYwsns COxVf2bEYzyhvz9zx71bzUyctpuo6RO9UqAeYtEMSHNowA706LmNJNHFG7qg9xfm 2g18vC1Huwg1X0fyyp6rXwuqQocyK6giVgvvD0KdYJtKa8e5oOSesu9FJUGryvX4 kNRl+JTJBSLNpemKAXkeQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgddugedvtdejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkfhggtggugfgjsehtkefstddttdejnecuhfhrohhmpeetnhgurhgv shcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtffrrg htthgvrhhnpeejgfdvvdekhedvleetueduffetieelhfeiueegfeffveejfefgheevffeg tddtffenucffohhmrghinhepghhithhhuhgsrdgtohhmnecuvehluhhsthgvrhfuihiivg eptdenucfrrghrrghmpehmrghilhhfrhhomheprghnughrvghssegrnhgrrhgriigvlhdr uggvpdhnsggprhgtphhtthhopedutddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoh epphhgsegsohifthdrihgvpdhrtghpthhtohepkhhnihiihhhnihhksehgrghrrhgvthdr rhhupdhrtghpthhtohepsgihrghvuhiikedusehgmhgrihhlrdgtohhmpdhrtghpthhtoh epughilhhiphgsrghlrghuthesghhmrghilhdrtghomhdprhgtphhtthhopehmvghlrghn ihgvphhlrghgvghmrghnsehgmhgrihhlrdgtohhmpdhrtghpthhtoheprhhosggvrhhtmh hhrggrshesghhmrghilhdrtghomhdprhgtphhtthhopehthhhomhgrshdrmhhunhhrohes ghhmrghilhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehlihhsth hsrdhpohhsthhgrhgvshhqlhdrohhrghdprhgtphhtthhopehgkhhokhholhgrthhoshes phhrohhtohhnmhgrihhlrdgtohhm X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 14 Aug 2025 16:44:15 -0400 (EDT) Date: Thu, 14 Aug 2025 16:44:14 -0400 From: Andres Freund To: Peter Geoghegan Cc: Tomas Vondra , Thomas Munro , Nazir Bilal Yavuz , Robert Haas , Melanie Plageman , PostgreSQL Hackers , Georgios , Konstantin Knizhnik , Dilip Kumar Subject: Re: index prefetching Message-ID: References: <7c308720-5cd4-4508-8cc0-6e55a6352731@vondra.me> <6wyxbnry2unm3kbcu2sabhzhs7baoedlg77xqm42chpofjq45g@igst42zpl7ok> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2025-08-14 15:45:26 -0400, Peter Geoghegan wrote: > On Thu, Aug 14, 2025 at 3:15 PM Peter Geoghegan wrote: > > Then why does the exact same pair of runs show "I/O Timings: shared > > read=194.629" for the sequential table backwards scan (with total > > execution time 1132.360 ms), versus "I/O Timings: shared read=352.88" > > (with total execution time 697.681 ms) for the random table backwards > > scan? > > If you're interested in trying this out for yourself, I've pushed my > working branch here: > > https://github.com/petergeoghegan/postgres/tree/index-prefetch-batch-v1.2 > > Note that the test case you'll run is added by the most recent commit: > > https://github.com/petergeoghegan/postgres/commit/c9ceb765f3b138f53b7f1fdf494ba7c816082aa1 > > Run microbenchmarks/random_backwards_weird.sql to do an initial load > of both of the tables. Then run > microbenchmarks/queries_random_backwards_weird.sql to actually run the > relevant queries. There are 4 such queries, but only the 2 backwards > scan queries really seem relevant. Interesting. In the sequential case I see some waits that are not attributed in explain, due to the waits happening within WaitIO(), not WaitReadBuffers(). Which indicates that the read stream is trying to re-read a buffer that previously started being read. read_stream_start_pending_read() -> StartReadBuffers() -> AsyncReadBuffers() -> ReadBuffersCanStartIO() -> StartBufferIO() -> WaitIO() There are far fewer cases of this in the random case.