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 1tAY8E-00GO1l-Px for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Nov 2024 17:23:18 +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 1tAY8B-00GJSu-QM for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Nov 2024 17:23:16 +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 1tAY8B-00GJSm-H2 for pgsql-hackers@lists.postgresql.org; Mon, 11 Nov 2024 17:23:16 +0000 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tAY88-001OYD-2f for pgsql-hackers@lists.postgresql.org; Mon, 11 Nov 2024 17:23:15 +0000 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-a9ec267b879so856926466b.2 for ; Mon, 11 Nov 2024 09:23:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731345792; x=1731950592; 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=HU7D1N5g1sp/7ahUkl8X/CWF6ZeATzYrIefzx1ltoNQ=; b=c9kokgVJTNqetnCIiSAUFcrrlGVzjVaTXPFBSZGg5FhEqXDMQPf23Cmyi0MMJ+zrZh V3AWE6BwSy6i4QeXuxuPdjlSwokIIJy8Zncxwte9rv1MtwclXmH9+eX9kQkDGEfxGwYl X6Y6L2VyAu7fgCuSrDPObn1g9/I9cdvPUvFP8z5sSBE5tOIDGHdv5I2f8yYNERIOMXwn ZUR9UPsqg52OFpYw97jnf/nTFIkaA21LpW2JeZfTxPe6/o1RFLcFbvio1RvvPbN/c5Aa gbPh/H19JhT6dRxzeFe55KT3cqNGKlhVSADo2GfW7iDdVb0UXukh76fMesZcBVrgTGuP ppwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731345792; x=1731950592; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HU7D1N5g1sp/7ahUkl8X/CWF6ZeATzYrIefzx1ltoNQ=; b=gkOKv1i8AoRmcn9zGuJZjyCfYQJfJlUlDH9ve1pyt08CTjmmu9WpWl3++dM6YyZZtM JRzxN+DOgGQi0mBKjUBMUXw6DIUA9ewppSfsbS8Ixb4k2W5k1B6Ciomb+ITkUThimI+V XjGgwm4i5hnIdczP+YFzkab+WLZ0Kk0EvfM5luRbvD7IwvgRiPPwlihA5UPrHn0DlnRv wgvRV6Xd2CfDl2riz6bFy3LXDyKiugh8J7yN5DWd4T070Ji4JJ19gBkWDkqrTKuRAcgg 9gHzO+iHI9FxiQ5bXJ1WEKLKqIGagw1xhJ4B+3380gP3zBUeErX5wkVhbMAytqHfShpU w0bg== X-Forwarded-Encrypted: i=1; AJvYcCW0rynjWsh43bvGnvjLQ1CW3mYKbG5RifAxW8k3Sw05xV3RVbZk3aEFyerFaHYdW/6OmLw6iWQIBhT/g4yz@lists.postgresql.org X-Gm-Message-State: AOJu0YwTojB9p7IOELTfGAYpVNfBYa6Bt+cP6jscgQFjMeT/Tn190OLG nkjzlB70j/AwQn5mGVsYRYSbyGBtPXsyCK0yIbQPsQjk9ECq/CUhDoStf0WCXFLX2HjPX5TYrzG 9J0SKm2X7QAfGPjQUTpPpv+medj4= X-Google-Smtp-Source: AGHT+IHjZB3qGdRjNBwH2/Wh7diZLXoxrhTRQafJNrts1bz8MNrZJT6YHnuDYlhDYJhFmO4lfjsp/0NTKj2IGwI3QvY= X-Received: by 2002:a17:907:2684:b0:a99:f3fb:f88e with SMTP id a640c23a62f3a-a9eefff3a0amr1414593166b.41.1731345791736; Mon, 11 Nov 2024 09:23:11 -0800 (PST) MIME-Version: 1.0 References: <4f5f16ef-df1e-4e09-9b3f-2e0961ab5117@enterprisedb.com> <20240215201337.7amzw3hpvng7wphb@awork3.anarazel.de> <48d3ff87-a435-488f-b803-258dab6485d6@enterprisedb.com> <6761860c-c66e-400a-b45f-aa741f548771@vondra.me> <8b58ae08-9ed7-43aa-92b0-1976ea6385ed@vondra.me> <225323b8-2c93-4784-8616-c58931a776bc@vondra.me> In-Reply-To: From: Robert Haas Date: Mon, 11 Nov 2024 12:23:00 -0500 Message-ID: Subject: Re: index prefetching To: Peter Geoghegan Cc: Tomas Vondra , Andres Freund , Melanie Plageman , PostgreSQL Hackers , Georgios , Thomas Munro , 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 Sun, Nov 10, 2024 at 5:41=E2=80=AFPM Peter Geoghegan wrote: > > It seems to me knowing which pages may be pinned is very AM-specific > > knowledge, and my intention was to let the AM to manage that. > > This is useful information, because it helps me to understand how > you're viewing this. > > I totally disagree with this characterization. This is an important > difference in perspective. IMV index AMs hardly care at all about > holding onto buffer pins, very much unlike heapam. > > I think that holding onto pins and whatnot has almost nothing to do > with the index AM as such -- it's about protecting against unsafe > concurrent TID recycling, which is a table AM/heap issue. You can make > a rather weak argument that the index AM needs it for _bt_killitems, > but that seems very secondary to me (if you go back long enough there > are no _bt_killitems, but the pin thing itself still existed). Much of this discussion is going over my head, but I have a comment on this part. I suppose that when any code in the system takes a pin on a buffer page, the initial concern is almost always to keep the page from disappearing out from under it. There might be a few exceptions, but hopefully not many. So I suppose what is happening here is that index AM pins an index page so that it can read that page -- and then it defers releasing the pin because of some interlocking concern. So at any given moment, there's some set of pins (possibly empty) that the index AM is holding for its own purposes, and some other set of pins (also possibly empty) that the index AM no longer requires for its own purposes but which are still required for heap/index interlocking. The second set of pins could possibly be managed in some AM-agnostic way. The AM could communicate that after the heap is done with X set of TIDs, it can unpin Y set of pages. But the first set of pins are of direct and immediate concern to the AM. Or at least, so it seems to me. Am I confused? --=20 Robert Haas EDB: http://www.enterprisedb.com