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.96) (envelope-from ) id 1w8tda-000z7r-0D for pgsql-hackers@arkaria.postgresql.org; Sat, 04 Apr 2026 05:33:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w8tdY-00FRVV-1V for pgsql-hackers@arkaria.postgresql.org; Sat, 04 Apr 2026 05:33:36 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w8tdY-00FRVM-0Z for pgsql-hackers@lists.postgresql.org; Sat, 04 Apr 2026 05:33:36 +0000 Received: from fhigh-b4-smtp.messagingengine.com ([202.12.124.155]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w8tdW-00000000TWo-2uOe for pgsql-hackers@lists.postgresql.org; Sat, 04 Apr 2026 05:33:35 +0000 Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfhigh.stl.internal (Postfix) with ESMTP id 256057A009F; Sat, 4 Apr 2026 01:33:34 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Sat, 04 Apr 2026 01:33:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc: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=fm2; t=1775280814; x=1775367214; bh=tfSz2YlMTM w3epao8eLprp3d1ulONdVjJW0qiGLxVjg=; b=Y5WVNQk9LZLKCYSiywQtZW6olf gGR85DFNlS1BJKhGwg5KKog+2IfaJycBmCwRhzCLlEkkU/ZSLQsPTdTRVSxPgqNo NuRJ7nd5vopRK+y6E5e4wBxnva7Np+g+IsE/bvs5EQNvAcUX6e7+7RsUpZOLR6xr IoqWuEZTWchW3gn6RyL+gOzgfY3W/dSKUGKmmByg5xNF5hioQ9zO0khqlSpSvg3v 6A5KFGEofkVXaI2PypwLpnrQOpxkWlEEWHU40O1jXzgWYxWNehSJLyaUSJZujaN/ gGEZJ1QevrFbz5rZZHK7qO1KYlHM2uvDW5U6JkvXsOv+oVEZyDN20Fy/ojVA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc: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=fm2; t= 1775280814; x=1775367214; bh=tfSz2YlMTMw3epao8eLprp3d1ulONdVjJW0 qiGLxVjg=; b=uJus0UTqmZJdG9ag9q9poHvj7cnMjSLSLvgaXc+S0WbCgDcoeH6 JHNw59YQ+I9DpPpQMBpRrp0w/edunV8siIdD0hdpPYkpLKPf5OVwHUBPopyDGCKs ovjYN5cToMIzp+DJxEduYS4KHEIgVLe1WSFHvp2b2WCgCUdwZxg1P1QQsbUB3ssw 9IQdYVBCjVjFU/mrQwGmTUTbX6kxFbxhypSHjQhtbVjlUyex1L+NAwHMCN9OMa/y ii3ebEKaVQOpLaBviMy5rdgqLwacJswnvlta+gc8YcQne1b9cDDqEreCWWp4Hww9 VJbI09O1OBlpieTs64wCjYjSec0U6AT22+g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdduuddttdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpeffhffvvefukfhfgggtuggjsehttdfstddttddvnecuhfhrohhmpeetnhgurhgvshcu hfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtffrrghtth gvrhhnpeeffffgledvffegtdevlefgtdeggffhvdekgfegteeiveejkeetudelveejhfeu geenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrnh gurhgvshesrghnrghrrgiivghlrdguvgdpnhgspghrtghpthhtohepuddupdhmohguvgep shhmthhpohhuthdprhgtphhtthhopehpghessghofihtrdhivgdprhgtphhtthhopehknh hiiihhnhhikhesghgrrhhrvghtrdhruhdprhgtphhtthhopegshigrvhhuiiekudesghhm rghilhdrtghomhdprhgtphhtthhopeguihhlihhpsggrlhgruhhtsehgmhgrihhlrdgtoh hmpdhrtghpthhtohepmhgvlhgrnhhivghplhgrghgvmhgrnhesghhmrghilhdrtghomhdp rhgtphhtthhopehordgrlhgvgigrnhgurhgvrdhfvghlihhpvgesghhmrghilhdrtghomh dprhgtphhtthhopehrohgsvghrthhmhhgrrghssehgmhgrihhlrdgtohhmpdhrtghpthht ohepthhhohhmrghsrdhmuhhnrhhosehgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgsh hqlhdqhhgrtghkvghrsheslhhishhtshdrphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 4 Apr 2026 01:33:33 -0400 (EDT) Date: Sat, 4 Apr 2026 01:33:32 -0400 From: Andres Freund To: Peter Geoghegan Cc: Tomas Vondra , Alexandre Felipe , Thomas Munro , Nazir Bilal Yavuz , Robert Haas , Melanie Plageman , PostgreSQL Hackers , Georgios , Konstantin Knizhnik , Dilip Kumar Subject: Re: index prefetching Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2026-04-04 01:21:53 -0400, Andres Freund wrote: > > +StaticAssertDecl(INDEX_SCAN_MAX_BATCHES <= PG_UINT8_MAX + 1, > > + "INDEX_SCAN_MAX_BATCHES must fit in uint8 ring buffer indexes"); > > I'd just use a < without the + 1 on the other side :) Actually, I think there are actual issues around this. Once you set INDEX_SCAN_MAX_BATCHES to 256, there are a lot of, justified looking, warnings. [1/1 1 100%] Compiling C object src/backend/postgres_lib.a.p/access_heap_heapam_handler.c.o In file included from ../../../../../home/andres/src/postgresql/src/include/access/heapam.h:19, from ../../../../../home/andres/src/postgresql/src/backend/access/heap/heapam_handler.c:23: ../../../../../home/andres/src/postgresql/src/include/access/relscan.h: In function 'index_scan_batch_full': ../../../../../home/andres/src/postgresql/src/include/access/relscan.h:488:45: warning: comparison is always false due to limited range of data type [-Wtype-limits] 488 | return index_scan_batch_count(scan) == INDEX_SCAN_MAX_BATCHES; | ^~ I'm also not sure this is actually quite right /* * Do we already have a batch loaded at 'idx' offset in scan's ring buffer? * * NOTE: a stale batch idx can alias a currently-loaded range after uint8 * overflow, producing a false positive. False negatives are not possible. */ static inline bool index_scan_batch_loaded(IndexScanDescData *scan, uint8 idx) { return (int8) (idx - scan->batchringbuf.headBatch) >= 0 && (int8) (idx - scan->batchringbuf.nextBatch) < 0; } once the differences between the values don't fit into an int8 anymore. But I'm tired. Greetings, Andres Freund