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 1tAZEb-00GTgy-4q for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Nov 2024 18:33:56 +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 1tAZEY-00GvPU-Eg for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Nov 2024 18:33:55 +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.94.2) (envelope-from ) id 1tAZEY-00GvPJ-4f for pgsql-hackers@lists.postgresql.org; Mon, 11 Nov 2024 18:33:54 +0000 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tAZEV-001M2y-NW for pgsql-hackers@lists.postgresql.org; Mon, 11 Nov 2024 18:33:53 +0000 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-a99f3a5a44cso647579066b.3 for ; Mon, 11 Nov 2024 10:33:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731350029; x=1731954829; 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=CPSdZR3LbHgBEVM4VgGiSRFGVw1wMSpkk3ZaAOK4zwY=; b=ClwDn3WS/sAlMDRWjTOAXzZQ2NRx9iV9Vhm5G+c7+1b3rcDWFnx4gclWhaCSDY1IA6 Ddai5FCHXwzrpr/wlUbdYAgwSgZskbJdJh0/N6L3tmPulIt9DjnJd6wKa0bZUd701nIu GYb0SHpgtZ2NXXgHVCt4DQfLaWavoZrm0XM1F9k8BzOKn3MYF7lLZ+/xk4bIlabhqtQx aagXoZiEFQ36P7K31k2thI4xeNgCQcDc65WV8In8Q9KEMy5HuCQfleiyhus7CuHx6/Tb prKwesFuimphjqAqMmhVUPVlG6KxUiwjMrVx/W/N0rLXmJ0dXumHKggYI69sTx58b5Bc akSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731350029; x=1731954829; 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=CPSdZR3LbHgBEVM4VgGiSRFGVw1wMSpkk3ZaAOK4zwY=; b=IbR9TfVaoxEM2MlNYvlPoQAJGsvLs5kOBhPLHU71qmGN+xVF7l5UanBrEJcjjaewMl 6CzaNSr0ooWRdruHMX2Zsi1m/L0wvIjYFbAR8qMR9NpCad72LiJx2GCxNZ+smSUoljOW oDT6srZLGsRW9AQAM2RQRbTgZoCSIJWTHxnGDP2qtbi38AChzFlczviLCGCDE1llk94s KUSzR8m+qHhJt9fYdkikK25863zULrHajF9WG/BzjPm8e4IsH6brErHRY06B7e7NBvnx R5caGzcI42G760EU4R+eQ4drE9PlLj/yNW7rZT5oSZuuw+C1BRYF0khbptPaZPuVseT0 tn1g== X-Forwarded-Encrypted: i=1; AJvYcCW94shwJu/SULFbkNl7lcZPSwM9n20qj4te91G4UltuZ9SZMG+QOoatgvGowxhoNSnuTsy2pueF3HVSs511@lists.postgresql.org X-Gm-Message-State: AOJu0YyX+3HugzQbKoWW3Ov6mcrCppdaPady1ZCHmaJ2MVgMtNmLPdVn mMWT2hjLynv5UMG5OJNuREE1wa0cn8YFeS+EqTdhZwRgddOZ0A85CNR9L3hL0NqGbovMbs3NZ/f Erhirq390A/3iQyF5DBx2/0rSs3g= X-Google-Smtp-Source: AGHT+IGQ9lmy8IkpVagLMSE75f19ZR64/SJ6/7qKR9YQSB569DEGHmb2QLr/FMyUrE4eeBvwavDQwL9rEoffoVPirz0= X-Received: by 2002:a17:907:7f1f:b0:a99:f4be:7a6a with SMTP id a640c23a62f3a-a9eeffdc630mr1392280866b.47.1731350028829; Mon, 11 Nov 2024 10:33:48 -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 13:33:37 -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 Mon, Nov 11, 2024 at 1:03=E2=80=AFPM Peter Geoghegan wrote: > I almost think of "pin held" and "buffer lock held" as synonymous when > working on the nbtree code, even though you have this one obscure page > deletion case where that isn't quite true (plus the TID recycle safety > business imposed by heapam). As far as protecting the structure of the > index itself is concerned, holding on to buffer pins alone does not > matter at all. That makes sense from the point of view of working with the btree code itself, but from a system-wide perspective, it's weird to pretend like the pins don't exist or don't matter just because a buffer lock is also held. I had actually forgotten that the btree code tends to pin+lock together; now that you mention it, I remember that I knew it at one point, but it fell out of my head a long time ago... > I think that this is exactly what I propose to do, said in a different > way. (Again, I wouldn't have expressed it in this way because it seems > obvious to me that buffer pins don't have nearly the same significance > to an index AM as they do to heapam -- they have no value in > protecting the index structure, or helping an index scan to reason > about concurrency that isn't due to a heapam issue.) > > Does that make sense? Yeah, it just really throws me for a loop that you're using "pin" to mean "pin at a time when we don't also hold a lock." The fundamental purpose of a pin is to prevent a buffer from being evicted while someone is in the middle of looking at it, and nothing that uses buffers can possibly work correctly without that guarantee. Everything you've written in parentheses there is, AFAICT, 100% wrong if you mean "any pin" and 100% correct if you mean "a pin held without a corresponding lock." --=20 Robert Haas EDB: http://www.enterprisedb.com