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 1vsPdt-004QDo-04 for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Feb 2026 18:17:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vsPdr-00BM3r-1i for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Feb 2026 18:17:47 +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.96) (envelope-from ) id 1vsPdr-00BM3g-0O for pgsql-hackers@lists.postgresql.org; Tue, 17 Feb 2026 18:17:47 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vsPdp-00000001EgT-0oQn for pgsql-hackers@lists.postgresql.org; Tue, 17 Feb 2026 18:17:47 +0000 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-482f454be5bso975675e9.0 for ; Tue, 17 Feb 2026 10:17:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1771352262; cv=none; d=google.com; s=arc-20240605; b=bJhX/cbVz/y1xP0iXOHJRXwQuD8nZBu0HQNuaqQeLHYbVecMkV8psmxkujhmVhmfPk oqj/RdcBXt4gUMs8AK5JPOSeNO51Va8mzGkKwNFBW4BLxQP3K50mD0PfAYUTkfwD9PBn eVfg6woPt3zQeqUKu/41kb+DtbHputDPTdxsBKBmvO6jDxDCFPskJZBG4iZ6HOWvCVJk YK16xhDOTdllPpWxK5swhYOqjtempi0jQVTVujJT520jayKXZNN2MhTW5E/qz1VB9xZ3 Uu1YJohQfSZKoXuetNlsiPVXS6ejWrPXxLZ5MczIhCyqvqHfn7xPhwcqZ71FiI2RS2b3 fZ4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=C5TImml5o691QDrfM2wucf714axUxORTnEB+ze9XYXE=; fh=TdFBha0jgFvR4scbOJJBNv6bjSG2QyJmONElE9vClXA=; b=SbRXAACqvKCeMkb8exXCctrjFaFZqH0xxlpy8t3BxE5rVWCtjntRiYX8M+O0Xs0+Jp WXQ48yR2i/1a+2E+5mbleSY4qgZU9LyfPP3Dch2TJ5DV33EXbT+ZgzRwAMXEoi0grsTh /wwT1JpL4S5df7V+0ctLcTk29mo0bXALfmIur5hl06TsKruiDtrJ5cqRpmcaDVRZ7cqX w4cyVrzOJjHTQa2eVT4AtrMXgTfQE8LV/RD9EuZtdvs9WES72BZEtxH8CBPmT048gXj8 +xtJ+j6YHmHmtaPl69laZEjoY6sT4/h9zBvcH5pEcOIharbiB4tr8ZWa2Bw6xdVrCobZ paaQ==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bowt-ie.20230601.gappssmtp.com; s=20230601; t=1771352262; x=1771957062; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=C5TImml5o691QDrfM2wucf714axUxORTnEB+ze9XYXE=; b=PtNRzzx03kefeB0poFD1I4mMfTg++5BZVhOGetmeTAGVadm7SKgqcimTYI4na13lGb a+3gQ+EF+MHrsyBMUQcNrFRl1c5EiSAlOaAMi2/RCNO3k5oCt8ohjCmnl/azMq0cv68q q2lr6Iwv1YXuGiMkGzZUcCCnSqp0++o/W3kOL8GM8wPs1cjexwoG/OMfichkQ+0k4Tyh WVFiSCEZTP5ruIlTwLZ1EGlL4pSoGVbQNfUFAVgPNq12nJnAuazbomtvY5ra7R1MMqul Z5v3CMpzSkSBRB40Q5BeIuB1b3t56cyj14Fq5p/H/2Ci1Yfm6gNe3BCbEhVGmNzgpNmj ouBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771352262; x=1771957062; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=C5TImml5o691QDrfM2wucf714axUxORTnEB+ze9XYXE=; b=C4zpE8ilxLHplqqS8v8kDWyw9OvxEVATSkNgk9Eh0ULE/zdQYGr0r75JduoIJUK4qK S+vlGEg15R62eWkYwGSswbxo3VKkcCdihMrnUe+FQwKdSHpDVrSi60OoIbn9MaidMMlC 6NLYrLWE/187aswo+YGG4q7YoldnqZFGPxPfyHNEQ4HDR/YXe8g3LjstIyGZoaF4IuBh X9Qf6ZtTrLS1L0RHjYbWI4LczBRiY3ixyNPCJwKK+FEXqWLcmnxjJnF9/f94VAT1SI16 y4Lmrmw5ufbrzewH5hux8zHHJBT9W1ymRMr4bQU/RIGwmor8ADYI8ABqLJR6lglPgTuo MPOA== X-Forwarded-Encrypted: i=1; AJvYcCVzztoLOrsTwJfou3oqM3wk++v6+ZaEEQzHNS5is9qtNIZ8PHw0m+G2pWEq4ykB2y70/AHDlUEFOvx6jJQ/@lists.postgresql.org X-Gm-Message-State: AOJu0YzgODT1PVsAlQ4ajvCyl45aUT4iH57+G4C3wCoDKjJ6xFmCUUOn Bd3BWULjEMVirpioZFmJAigbwwuerlNWp5bZzIp0UssFvRAZlaGVXMNqXu1zoyOt55Jr3UyF36W 8hn3JidwfZxox4i7nSfVoBmtX0RSuJUPuCItSaF9Vow== X-Gm-Gg: AZuq6aKqxSkAwJWE+e/vQz5PI83BQ9u24HCk4qQtYacegmc7xeFoE1jahCkR08jXb8D soxgzaQSXdhL5B4PWRVFwskM0GtJGY7FFWAfeQsf0N8OBcqhjQeVGkjT8KJKEQtirsk5f2PMDGW J4tNt+e1aynlsfbIOfx5DZARSEL25UgSzdvINva4ROx0DaxkYhwy7px+8GRfaWMvyoA+HqNchic 1aj2oOB/vZnBJq2wPxoNcjCHHgqTQm3CqNLSzTULWhbSr/lvWqGYtSMr7+pekkKhyRsJ1+lmgG0 oQWYthk= X-Received: by 2002:a05:600c:5595:b0:47e:e0b3:2437 with SMTP id 5b1f17b1804b1-48378d62897mr144643595e9.5.1771352262411; Tue, 17 Feb 2026 10:17:42 -0800 (PST) MIME-Version: 1.0 References: <9411f220-007d-4f1e-9c8f-ca8eb09e6788@vondra.me> <984dcf9e-ada0-4dff-ae58-1f97bc904ccb@vondra.me> <7herwtpae3ptqdng3s7tcft4ljkc23fyocp3mbrvc7xyk7s2lk@uq3qbm4blizo> <433c7359-3c5d-4fe3-a488-93a17f44d0bf@vondra.me> In-Reply-To: <433c7359-3c5d-4fe3-a488-93a17f44d0bf@vondra.me> From: Peter Geoghegan Date: Tue, 17 Feb 2026 13:17:15 -0500 X-Gm-Features: AaiRm53yJi8HucQTlia7eHz6LFUMWKyBiGmSm3yihxACIJqGf9lAzX-JFwXmDsE Message-ID: Subject: Re: index prefetching To: Tomas Vondra Cc: Andres Freund , Alexandre Felipe , Thomas Munro , Nazir Bilal Yavuz , Robert Haas , Melanie Plageman , PostgreSQL Hackers , Georgios , Konstantin Knizhnik , Dilip Kumar Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Feb 16, 2026 at 10:44=E2=80=AFAM Tomas Vondra wro= te: > I've described this exact behavior a couple months ago in this very > thread. The queue of batches has limited size, the prefetch needs to be > paused - at that point read_stream_pause did not exist, so it was done > by terminating the stream and then read_stream_reset to "resume" it. > > That has the unfortunate effect that it resets distance to 1, and so it > easily led exactly to the issue you describe. But without the pausing it > would work perfectly fine, in many cases. Just to be clear: it *used* to work that way, back when we weren't using Thomas Munro's built-in pausing mechanism. Because we'd actually reset the read stream back then, as a workaround for the lack of any built-in pausing mechanism. But we don't do that anymore; recent versions only reset in cases where it's strictly necessary, such as on a rescan, or when the scan direction changes. Recent versions of the patch are just about impossible to make pause. Because (for better or worse) we'll yield before ever running out of batch slots/before ever pausing. Andres has shown that this can be detrimental to our ability to maintain an adequate prefetch distance. But that's likely only because pausing hurts when it prevents us from aggressively ramping up prefetch distance at the start of the scan. Even without yielding, pausing is rare and likely doesn't hurt us much. After all, 64 batches is usually plenty. > With the resetting, this effect is pretty brutal. What resetting? We don't do that anymore? And even back when the patch did things that way, we made sure to save the old prefetch distance (which was a kludge upon a kludge)? Basically I'm confused about why you're now talking about how the patch worked months ago, which was always a temporary workaround to deal with the lack of a built-in pausing mechanism. All of our current problems are due to yielding (not pausing), and/or issues on the read stream side. --=20 Peter Geoghegan