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 1w8TyA-000ZqF-1U for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Apr 2026 02:09:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w8Ty9-009Ju9-0E for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Apr 2026 02:09:09 +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 1w8Ty8-009Ju0-2Y for pgsql-hackers@lists.postgresql.org; Fri, 03 Apr 2026 02:09:09 +0000 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w8Ty6-00000000IhH-0y60 for pgsql-hackers@lists.postgresql.org; Fri, 03 Apr 2026 02:09:08 +0000 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-b97f9587e6eso205134066b.3 for ; Thu, 02 Apr 2026 19:09:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775182145; cv=none; d=google.com; s=arc-20240605; b=WXHWx5CUVHr1RDtLfZTAM3yJ3e034HojKSm9CuOEk1f0gzF6/gvudLfQ0Ss+2md+Ay pZammqroo+0AwYtIvrG9MhBItjFNJd/dJByTNf3l7+8odNVw36KqoixvW29vuCyyXQlG NVmBeGTWQ80vW+FxLk9ouIx9VxsmlftkdEbpq6WwlbBFtgMjTtvm5JFpm+XH5eWgvtG4 ekw4ttqfsgtV1bTKnR1pwvP1h8wKztpsQIngmdvOZJbWAeEz9GTpRJWeogcajI4VsnjB Odib1K0G6NITxR0cKVGqqelmKAQavUZrO4WEM/3uJ5a4AbckR0kACzMxWEu2kL7op/d+ lOgg== 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=MXGm/mHwKiTDbe+h1yCga2rhyR+Gkt48+pQtthkoHD8=; fh=xX+sVIaXGg+pAofw0sktJY2xi9z3hrnDN8eAkYgPoNM=; b=iwnZbPMv/8iSR0kA6zYNO+dl4LrLcW/WL6PHa2s6n+/n/es3arhE4nv1DxeSS88KHS oa50LTdVSgPVkh/ytCj9gPR2XFUMSda3+NfW0cLZ523YOH7Gi4c9c6sSjmN0qCKwKwrj mk+GsIDmbj/ivdvrHG1lMr9Yd+vvpAf5AFWhPUQSMtyeldYxWaJ3QiQIfiXU9yPPArrz v79kFz+semVQ2Za2WxWJELJSNzuBD9u1Kj3Xqa/BR0xpxym5gTQw1jO1yGFSFkT0KDtG GylonIWQRIvqGE8k8tWMoV/JXnVpdam2AuXCCSaC/ezAxFpWWVGh/Khc0b1414z6hgDC LLYQ==; 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=20251104; t=1775182145; x=1775786945; 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=MXGm/mHwKiTDbe+h1yCga2rhyR+Gkt48+pQtthkoHD8=; b=o05kN/Q+2Q+HL0b03jwNtk//H/G7SIkZ6wy0mgvoS+thRm9ZhsG478E30shoyHHT/8 HRzGpnkMsdDr13lTbJuVWBBMx7f/4WqpW9zD/j7IxAfl8Gsr6UDGfNGJ/j1BM2FxmLe/ qrhEMoyKrm+z5kle7jwg1BFkyULA7ePVMJwC6vQbQzte/0ptB88vLlEWals2FHHyhsuG jjmlL1IcbM8QMJ0YfLSntE9L8yM/xPjcSUmRksSWvKROwiUqPs6xhOC5Lb2WodjvO+Qf dMKkn6J7jEWBrnYKjVdcRa3jARoF9LY8AQtTvmjTn+DXKX6Pj7gay7qzcNeM10hGejCi NXxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775182145; x=1775786945; 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=MXGm/mHwKiTDbe+h1yCga2rhyR+Gkt48+pQtthkoHD8=; b=mUqYD7yizFcNnpOa6PwovehclDbq6hYLGgAv6ypm19fZ0QhpA/izG3ANRwEfJcuZYY DWJ8rfo/7Y78trzmITm3D91RwUb9JhhD3PJgjI3/XOACwcDMgTglNP7Y+l4V1IJmEPa8 Kbgrk9Ab7Q0SsHZwMZKZ7sGExyXlQQQ0xp88nHbN5KCWyY5E59PEbERwoBwLo+2OKFwf fp3C9dOEBQ0R5K5X7i6EeHA8QRV6sZU2vOUE6c2JOHxy8uWvI8EKrHT+rQSN+ZS72XNA R9MJDOoNdu+I8tpLQvBFu0o11VwAW2UaHtrPejv+SF28iTmikMo0Dyi6MN61z1gP7ny8 MzIA== X-Forwarded-Encrypted: i=1; AJvYcCWU4EZre8bVfmGL5MMTMFo2YX8UqppVnYPh+x/YS2ufk2hUWDiCdyhLgF9vY1sEMD/iGvZ3kT3KK3E+I7KZ@lists.postgresql.org X-Gm-Message-State: AOJu0YwSl03tecCO7tXBefUbsrGZq07si1VRp/jwaEPMDtmSh5i+/t/E FoGFPj0EyjX0XrUjf5nlmcGw3CibjZge+Q3V8x/z5E1Li0pV7UxrfXXpL8AyzST3zBJyBwqwuim Xp20SxJh+oSI1WChQ6YHsT+QWHvUUcgjLQQ== X-Gm-Gg: ATEYQzwzVdyC2C468GlJMrWc10UtNh/GpCzYP0UVtik3xeJhcyWd6HW8QygpDtsCv+l /cSKXlOD+LDjiH3cxBHpoi04YpDje2HaKUNA8X2ZzvyKAJtmRluRXuithDqt908a4v5CA5RN6Uq wUL1tYsQRkAwulrqt6afLEJFzHC5QK/VzGsnFFXLNB0KC4f2KIG6sdXmQ2U1nbB5hrY7pH0x/Kx aslOdYUjAhaT724/jdMh1xoYqLc4lZoOLAbD9cfBPMJvKhZSx3vS8V81ee8udYdA37oRqlPAD+o x3A1iaPZwd0pRMVKh1hAeXlEc7NQ40ViR+VEkqw= X-Received: by 2002:a17:906:b389:b0:b98:27de:2e0d with SMTP id a640c23a62f3a-b9c67b4751bmr37411966b.46.1775182145241; Thu, 02 Apr 2026 19:09:05 -0700 (PDT) MIME-Version: 1.0 References: <1299934.1773938807@sss.pgh.pa.us> <3683430.1775173413@sss.pgh.pa.us> In-Reply-To: <3683430.1775173413@sss.pgh.pa.us> From: Robert Haas Date: Thu, 2 Apr 2026 22:08:51 -0400 X-Gm-Features: AQROBzCko8BJa_uCjqmJeOAP0lw3C1PKHajSWytOtV1srSZ2uvQTx7SZdc8zfis Message-ID: Subject: Re: pg_plan_advice To: Tom Lane Cc: Alexander Lakhin , Lukas Fittl , PostgreSQL Hackers 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 Thanks for the report. On Thu, Apr 2, 2026 at 7:43=E2=80=AFPM Tom Lane wrote: > After looking around, I think the likely explanation is that the > concurrently-run alter_table.sql test feels free to mess with the set > of indexes on onek. It doesn't drop onek_unique1, but it does > momentarily rename it: > > ALTER INDEX onek_unique1 RENAME TO attmp_onek_unique1; > ALTER INDEX attmp_onek_unique1 RENAME TO onek_unique1; Yeah, the fact that it said /* inapplicable */ strongly supports this theory. There's only two ways that can happen, and an index not existing with the expected name is one of them (and the only one that's possible in a query involving only a single table). > I've not looked closely at pg_plan_advice, but if it matches indexes > by name then it seems there's a window here where the advice would > fail to apply. Also, further down we find > > ALTER TABLE onek ADD CONSTRAINT onek_unique1_constraint UNIQUE (unique1); > ALTER INDEX onek_unique1_constraint RENAME TO onek_unique1_constraint_foo= ; > ALTER TABLE onek DROP CONSTRAINT onek_unique1_constraint_foo; > > which means there's a window there where there are two plausible > indexes to choose. Will test_plan_advice cope if the transient one > is chosen? It's going to be unhappy if the second planning cycle is incapable of choosing the same index that the first planning cycle did. I have to admit that it didn't occur to me that our regression tests would do something like this. I figured they had to be operating on mostly independent objects or things would already be broken, but I failed to consider the possibility that there could be concurrent DDL of a sort that wouldn't affect the normal running of the regression tests but would affect pg_plan_advice. Or at least, if I did ever consider it, I stopped considering it when test_plan_advice appeared to be passing. > So I'm not sure what to do here, but we have a problem. I'm not sure, either, and I agree that we have a problem. I'll give it some more thought tomorrow. --=20 Robert Haas EDB: http://www.enterprisedb.com