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 1vuVyA-00Agpv-38 for pgsql-hackers@arkaria.postgresql.org; Mon, 23 Feb 2026 13:27:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vuVy9-00DO9M-2l for pgsql-hackers@arkaria.postgresql.org; Mon, 23 Feb 2026 13:27:25 +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 1vuVy9-00DO9E-1P for pgsql-hackers@lists.postgresql.org; Mon, 23 Feb 2026 13:27:25 +0000 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vuVy6-00000000nnG-08C5 for pgsql-hackers@lists.postgresql.org; Mon, 23 Feb 2026 13:27:24 +0000 Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-b8f992167dcso531586366b.1 for ; Mon, 23 Feb 2026 05:27:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1771853242; cv=none; d=google.com; s=arc-20240605; b=VJpxBDPQcXheX2SKL2Y2wSW5apC6Molp3XRsmatusg3WclsOTO6Pl/L0a4JelwN+Tw K3WKDKtvQxiq3P6U9eIvdHcBLxTP8c/1nVTDEn0PtxuiWPSjms7/nMroUfOzEMupGo+0 WgEmxRYmOvVSPm9ySpR2ZYfjAuo72uVAHAdJ6stCb34bYKjP7TQuKReSX4KeGJO2mq6q EdYcW+3XZcaQbMmFD1UpvNfOvN3dzXv76tctj/aZLUq63zE8SCpHram5wFod+J4k2OHA KysQbYFj/VaeatZeWPbUOFBZQ49iya53q7GxsVx/akQmAGJsAXIxd4nOT2wAupD2JyR7 rrcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=ypcgNMK9+P5vH1PyQF+l/JDMlD/GVZSqOkeodmOFC3M=; fh=fLw6prVEzBjgvjbfBW34Vg4XORwCEilK0CzqyMxJmNA=; b=blmDpgNCKR1mpkms/ViGCs+qmKIV3s1L6P8D2t3DsyXIu+3yXh53aZTmnb2L9OXTiN f28/HZY3C5qx4gk1tAPfmDk4ijg3hixBDFVUAnVvE+vb2SZ7b24uKmLH6b8q2OlDd6/S FUcivPL9oM8hjlB61kvGrElJp4fgOzvXPWi6SUA3i35VrBG9Iw9se5ETu5AYxxpsEUQC cAOClVfwFauiqrGCqmMDPofWUjrAKFkyJX+AOzFwC+tyWVKZnoj2RCWal25Uge0UJnJX P9dzMly3CktuZcHfPprKWXbBmY/RJBSn+8fsMF9Ii6qQGRqfV7i/1TN2bZu59L9Etnvd bEEA==; 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=gmail.com; s=20230601; t=1771853242; x=1772458042; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ypcgNMK9+P5vH1PyQF+l/JDMlD/GVZSqOkeodmOFC3M=; b=TjFtKF8Wo/CJAYgGNScTygvfHw1EtmcGVj0g3M6XTVSC3o14XGgKtATVWBXubznnP+ 7nJYVyGbaKcH1RJdlvEFCR84+qY29O/xvMjAO8eecL0PK/ipLx9syJHUT/SjK/P6zB5k w//Hg9PaUsG7gxYBT4myD3/ZsKzoUjIPDlk9+SKbdgmBf7WKv+vQB9+BP4aqJOMHWMF0 N5js0DJ6tZ8oUsUk7a3WYUYi7F6xNcbEngi95kpLOXegvLGVJXZamq95sOH0tmPkT3rt WLRLSm4tgWOiy0vYaK1JB/b9grZMDiTRJDrt2mdlEOnHtcY/PVhJ/s9gLsCkuA6EQtNG DLoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771853242; x=1772458042; h=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=ypcgNMK9+P5vH1PyQF+l/JDMlD/GVZSqOkeodmOFC3M=; b=NDyjUuUtLjuJ1upiMhN/6/qa+eIycLri7S8ZVC0uzubAddqhR5pV4uPLJYG2yLOF5h CDcej5yJuD00Ropyc8Pc46s5gNwTMJlzfsftkSPz4YVzkWQ/9LNG/9jeNrkNELosDix2 dTNo9mRoEDT6wOgZusHqVXNDWY0au/bHrI1E3MQt66zNXfOOUdziAlZ55PHcX+5V+5xe SgJTZ6QYBq8029DPjQrgqNGjkWxu6Pu/dQW5yBF+WIeS1l2ogXEcbeb79nDbbJxoOyTd oCApxIrSM41zHmYYo17zahLRYZStR5wq0nkNy6gaMXQtaT4ZVOpuFFS4a54vsHfsqRCN YBeg== X-Forwarded-Encrypted: i=1; AJvYcCX6bkGTj93ycrWVhcZeZOXJbjA0xVjMzQmz02w9IH76gT8CX6Nat7GPTk/dm1a9bB45VrHvU0GxMbyTEzF7@lists.postgresql.org X-Gm-Message-State: AOJu0YyE6HqoGTr44W0R5bbby9Y6rFA6ihr+JfkazfXaPAnlXo56w8SX PRjkigZPIpAfJy6r2iUjpsKLpjiMFHcBDPHZ84qSqTDt0HFAYzlbc7qfBsPFm1VhRYZoZVRgN9T fHC60OnzB4XKRbam9prIJwH3Q6oONJ7s= X-Gm-Gg: AZuq6aIKBPByREvIuxn3F+qMLD0rC0m3AXjfoB38tXc1Cvt9vGs9KCuHMybtRt6Hp5o FqdsyQoxoBahpvCc6OdCDUmSSXaogs1AcBNh7iPaI0pxs2ROSPsGvGh+JTK8oG6WZKBeBR+ueZu 0b8Voi13i7MkkWWMEBFKBhC9fDOQFnqCU8LeEG2ydkportj5U3YVwnFEhslRy5fE6duD0hiDGxx lItKe5UAbkKwwdb7x620BeBY3yaYsBUmAYI6KGv774ZMITi6kUHnE4lSGV31phCOyETtLkhaNCu M2eRx3aaY8ZHOQqxgbN7S5OPKjB86Vz1pxyS6HquoENmQH2jEw== X-Received: by 2002:a17:907:d15:b0:b87:28f7:d3b6 with SMTP id a640c23a62f3a-b90819bdecfmr474035466b.19.1771853241323; Mon, 23 Feb 2026 05:27:21 -0800 (PST) MIME-Version: 1.0 References: <64a2re223ajj4popowsyu4xekbuvvyfwkrihn5yzyrkwsmsuvp@2lls3tpww5dl> <52512325-b1f2-4fff-819e-f68122b2e427@vondra.me> <64mfcfv7iihc4pmqlxarii4esnmqry52ckz5m7lmwylnfnuxuz@oxh4ioxkjtep> <720560ca-97b9-40a1-ad40-9f9b8a6648e9@vondra.me> <2f7fdaa6-2855-4a49-884c-16b91db9a97b@vondra.me> In-Reply-To: From: Alexandre Felipe Date: Mon, 23 Feb 2026 13:27:09 +0000 X-Gm-Features: AaiRm52_hEfwavfy8wIBY2DXYrlPMzVZQUwUv23ersjgn7MIwdSV4rGvO-igqsA Message-ID: Subject: Re: index prefetching To: Peter Geoghegan Cc: Tomas Vondra , Andres Freund , Thomas Munro , Nazir Bilal Yavuz , Robert Haas , Melanie Plageman , PostgreSQL Hackers , Georgios , Konstantin Knizhnik , Dilip Kumar Content-Type: multipart/alternative; boundary="0000000000000b1535064b7dbb2c" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000000b1535064b7dbb2c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > We're in crunch mode right now, ahead of feature freeze, which is less > than 6 weeks away. BTW, it seems that someone forgot to #include "utils/rel.h" in src/backend/access/transam/xloginsert.c > Tomas has been working on this project for about 3 > years, and I've been working on it for about 1. That is why I gave up on contributing a feature that I wanted back in 2022 (that could make some of our queries dozens of times faster queries). Before going for it I tried something easier staying away from critical things like IO, contention, replication and submitting a planner improvement (5479), and while I waited I decided to look for high impact features. That is how I ended up in this thread. So even if I am inconvenient you can look at my presence here as a compliment! > Long digressions about > the asymptotic complexity of priority queues add less than zero value. Sorry for that, for some readers that could not be obvious. Let me know if you think there is something where I can add greater than or equal zero value. On Sun, Feb 22, 2026 at 7:28=E2=80=AFPM Peter Geoghegan wrote: > On Sun, Feb 22, 2026 at 11:23=E2=80=AFAM Alexandre Felipe > wrote: > > DISTANCE CONTROL > > > > I tested different strategies to increase distance. 2*d, 2*d+1, d+2, > d+4, and so on. In my head, what would make sense is d + io_combine_limi, > but in the end the 2*d gives the best results across different patterns, > e.g. (h{200}m{200}) that seems to be a more reasonable pattern, as previo= us > scans would have loaded in blocks. But these are fundamentally the same, = as > I posted about this a markov model, and the limit will be something like > max_distance * sigmoid(h * (p - p0)), what changes is the transient when = we > go in and out of a cached region. > > I don't understand. Why, in general, would a Markov model be useful > for determining prefetch distance? > > > LIMITING PREFETCH > > > > To avoid prefetch waste with a limit node wouldn't it make sense to sen= d > from the executor an estimate of how many rows will be required. > > There's a patch that does that. Have you looked at the patch series at al= l? > > > I/O REORDERING > > > > I did an experiment reordering the heap accesses, following a zig-zag > pattern > > There's no question that reordering heap accesses is an interesting > direction to eventually take this infrastructure in. I've experimented > with that myself. But this is the worst possible time to be increasing > the scope of the patch for an uncertain benefit. > > We're in crunch mode right now, ahead of feature freeze, which is less > than 6 weeks away. Tomas has been working on this project for about 3 > years, and I've been working on it for about 1. Long digressions about > the asymptotic complexity of priority queues add less than zero value. > > -- > Peter Geoghegan > --0000000000000b1535064b7dbb2c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
> We're in crunch mode right now, ahead of feature = freeze, which is less
> than 6 weeks away.

BTW, it seems that = someone forgot to #include "utils/rel.h" in src/backend/access/tr= ansam/xloginsert.c

> Tomas has been working on this project for = about 3
> years, and I've been working on it for about 1.

=
That is why I gave up on contributing a=C2=A0feature that=C2=A0I= wanted back in 2022 (that could make some of our queries dozens of times f= aster queries). Before going for it I tried something easier staying away f= rom critical things like IO, contention, replication and submitting a plann= er improvement (5479), and while I waited I decided to look for high impact= features. That is how I ended up in this thread. So even if I am inconveni= ent you can look at my presence here as a compliment!

<= div>> Long digressions about
> the asymptotic complexity of priori= ty queues add less than zero value.

Sorry for that= , for some readers=C2=A0that could not be obvious. Let me know if you think= there is something where I can add greater than or equal zero value.
=




On Sun, = Feb 22, 2026 at 7:28=E2=80=AFPM Peter Geoghegan <pg@bowt.ie> wrote:
On Sun, Feb 22, 2026 at 11:23=E2=80=AFAM Alexandre Felipe<= br> <o.ale= xandre.felipe@gmail.com> wrote:
> DISTANCE CONTROL
>
> I tested different strategies to increase distance. 2*d, 2*d+1, d+2, d= +4, and so on. In my head, what would make sense is d + io_combine_limi, bu= t in the end the 2*d gives the best results across different patterns, e.g.= (h{200}m{200}) that seems to be a more reasonable pattern, as previous sca= ns would have loaded in blocks. But these are fundamentally the same, as I = posted about this a markov model, and the limit will be something like max_= distance * sigmoid(h * (p - p0)), what changes is the transient when we go = in and out of a cached region.

I don't understand. Why, in general, would a Markov model be useful
for determining prefetch distance?

> LIMITING PREFETCH
>
> To avoid prefetch waste with a limit node wouldn't it make sense t= o send from the executor an estimate of how many rows will be required.

There's a patch that does that. Have you looked at the patch series at = all?

> I/O REORDERING
>
> I did an experiment reordering the heap accesses, following a zig-zag = pattern

There's no question that reordering heap accesses is an interesting
direction to eventually take this infrastructure in. I've experimented<= br> with that myself. But this is the worst possible time to be increasing
the scope of the patch for an uncertain benefit.

We're in crunch mode right now, ahead of feature freeze, which is less<= br> than 6 weeks away. Tomas has been working on this project for about 3
years, and I've been working on it for about 1. Long digressions about<= br> the asymptotic complexity of priority queues add less than zero value.

--
Peter Geoghegan
--0000000000000b1535064b7dbb2c--