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 1w8w6x-0011OV-0Z for pgsql-hackers@arkaria.postgresql.org; Sat, 04 Apr 2026 08:12:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w8w6u-00FeGY-2C for pgsql-hackers@arkaria.postgresql.org; Sat, 04 Apr 2026 08:12:05 +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 1w8w6u-00FeFw-0m for pgsql-hackers@lists.postgresql.org; Sat, 04 Apr 2026 08:12:04 +0000 Received: from mail-qt1-x832.google.com ([2607:f8b0:4864:20::832]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w8w6s-00000000Ua7-2bsc for pgsql-hackers@lists.postgresql.org; Sat, 04 Apr 2026 08:12:03 +0000 Received: by mail-qt1-x832.google.com with SMTP id d75a77b69052e-50d6b9bca48so19294081cf.2 for ; Sat, 04 Apr 2026 01:12:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775290322; cv=none; d=google.com; s=arc-20240605; b=ByubtJhBEoZkCesg3ub+Dyo4VjgHBxJTX8WspXUMw0Tyvq+tyykLz87sfP5LOqY+As SMjBkf3oyxr1+/0cfWjDzf/KFc1ar1hQpMrRb8DAlOixDSwGpq95t3EYKDEp/PiT5FVQ 6dDx0DU4D930QrusRYOcDmET1c1LIY5bzKdJ/GKX1c0Gw7JwZZt13ULfmprCDZmDcozh 0gqv7v9azTu5zUOPRdeIjjdUqJYQLnRYIuswhTzMKPWk/hEinlLZC+2rvUBmhE0W5yz+ xJdQNyIWHQzTbv34g7AMR5YIer9q2m82uEYu3lCwK2qr2PyBjsHKahoePRHFh+5z0+fX qLqw== 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=ENr5YwKE4+2wAlaXtoRqBnNzCU3/rnidArjUt307o0s=; fh=X5RylSVyRL+tWKn4bHti9Gfoyvrp/O/EfEOy2uOOCPE=; b=LyYkMOeELBKmZZhYfi7yP+4vwZZoPgGepR9uF0Wk2a0l0IK7tAT9VU2GGEwVzZo7M6 SkWN9r9ljvZ8iw92bWsNkQLfKsgDbsAmgclqG0ZBTT57SC4w4tJSW0AcXnKVtjYvaQ2B CqWmNOxq9wNVXQOhw8YUgG77pOtB7pO58lSqw7E2gSEYEOhZ2IR3JNSYjlXeVT1esz78 Q6zJ4l6hKtl7LLeyhhEGJYlMJltBLsU10N2Exe8jk1iD391wvz/rAXhwV6tCTuhr+eZt ndNmyGQaLMh5pLP/UU86/0Y6YhIfVSzax1iPj9nP5ra8SSp24hxfQCXCsTAgEgx+GPhE qYbQ==; 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=fittl.com; s=google; t=1775290322; x=1775895122; 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=ENr5YwKE4+2wAlaXtoRqBnNzCU3/rnidArjUt307o0s=; b=j9uKG+QGnXBgq7LtdkNwLQ0i6I+rtjOQ7ccc25pANR5GXWRUkTzVkO6Kcv+9aGR37A ary/1pQ7Q4wmgHA6UfCnpzu++XpJ+PEVqeyySbIe1vKBVB3i5OilxAnvNL0yFF0tpFuL Rsp8XU2xQDjIAobstYqmQv2UqAQytXhVJS2LU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775290322; x=1775895122; 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=ENr5YwKE4+2wAlaXtoRqBnNzCU3/rnidArjUt307o0s=; b=i/OlQ0KG8dFm293uDkE5oGKPGKrf/2rjb1GR1aMzRpF7RayqJquKaPEBQkKqqvGruv J4DiuYtJ8WMXwJXfkQmGfl/jdIn5gBskuwGtOFskcYKM4E5BT7Ga0Jn4vzLYxyWkmGDl p7iOmw/lxhEgNNFa2mALEkqOLPnqXAHa9DK1ZFXPO+ZR/9b7TVIkyTn2i0/QR8d37O4F PUMo9+0cN2nf00mCOplRVl55VQLZBmBmXQiMVhd61sXy9IjHkyeB7skaOSFmwfwlsh48 Rd6pr8HI2UHlOyL49FNcQiisKCdvQK00wDKTG7IvDTyeRF/VKYyuQOHwf5NMm0i3iKTX 2kpQ== X-Forwarded-Encrypted: i=1; AJvYcCWZYmnkyjfQVJvUFXNudIspMh5Crx858PbwFNerMk+dzufPqYa0s4/ZdEemTxHIUcUkITWNT726A4LMe9/N@lists.postgresql.org X-Gm-Message-State: AOJu0YyiwJMQJQeAUFdeMK2nwthXlkW6z7li730QHsMefOrSw9QJPH0J 33iWs9Er0jVCzIH3/WgKwV8Ac7ll0/NklXZXvrpOIgrf1yu2eih9iyl9wRko7y2c09M8u+d3cTj xLzQiQ3jz54HW3zzEKo30fWCnZWUuL7KAzffFHc54 X-Gm-Gg: AeBDieugRrEsN4Cvn6gGeTxlMYv1pqrduPVIt1T76zCa4U3jxB1PzGwMR2xCKmInw4G L5xn187AHkNQLORA9ZErg9TsSWxOeedUo5LWcycuhSQGAbYYfcsH1Wqgy/lmy80wOhG6XgVlS0b s1sesGsZrgIuh0pvRxenPz4Z9O/ujX9+Ye040XPFhkI6OFCMIwTrGUQAnSxm35fMvT0V5tPAwxU YNSW/7HKvjaleIPAkVMyVjI0j8PgG/oU4drqjvjYBhXJoFHO54exz8nzvmRLM7ECERuO1CVV6c+ l9r6fzyvejSR6iceN9OOLE+O0PHO2LRVeTv0c1r4 X-Received: by 2002:a05:622a:2586:b0:509:44c3:5fe7 with SMTP id d75a77b69052e-50d62aced63mr87766061cf.46.1775290321673; Sat, 04 Apr 2026 01:12:01 -0700 (PDT) MIME-Version: 1.0 References: <1136161.1769654478@sss.pgh.pa.us> <1299934.1773938807@sss.pgh.pa.us> In-Reply-To: From: Lukas Fittl Date: Sat, 4 Apr 2026 01:11:25 -0700 X-Gm-Features: AQROBzDTiakSPsZ9bVEQPUJOL0yscveHOoi_BOCFyBN_H7rlKzhWKWvwnMvdDHk Message-ID: Subject: Re: pg_plan_advice To: Robert Haas Cc: Jakub Wartak , Tom Lane , 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 On Thu, Apr 2, 2026 at 7:15=E2=80=AFPM Robert Haas = wrote: > > On Thu, Apr 2, 2026 at 12:15=E2=80=AFPM Robert Haas wrote: > > So here's v24, also dropping pg_collect_advice. > > That version didn't actually pass CI. Here's v25. I've reviewed the pg_stash_advice code and documentation, and I think this is overall sound. As I mentioned previously, I think its a very important addition to make pg_plan_advice work for practical problems end users encounter. To me this looks good to go, with three minor notes below. For context I've spent a few hours today going through the code manually, and doing testing. And thank you for the detailed notes in your earlier email, and reworking this. Regarding authorship, I'm happy to be listed as co-author on the persistence part if you want to keep that in the commit message. Overall I'm also willing to put in work during the remaining cycle to test/review/address issues in pg_plan_advice or pg_stash_advice, so we can hopefully sort out the other items being discussed. For 0001: > diff --git a/doc/src/sgml/pgstashadvice.sgml b/doc/src/sgml/pgstashadvice= .sgml > new file mode 100644 > index 00000000000..ec60552a447 > --- /dev/null > +++ b/doc/src/sgml/pgstashadvice.sgml > @@ -0,0 +1,216 @@ > ... > + > + > + pg_create_advice_stash(stash_name text) returns void > + > + pg_create_advice_stash > + > + > + > + > + > + Creates a new, empty advice stash with the given name. > + > + > + > + I think we should document the restrictions on advice names here (i.e. they must be alphanumeric or contain an underscore, not start with a digit, and maximum NAMEDATLEN). For 0002: > diff --git a/contrib/pg_stash_advice/pg_stash_advice.c b/contrib/pg_stash= _advice/pg_stash_advice.c > index 15e7adf849b..1858c6a135a 100644 > --- a/contrib/pg_stash_advice/pg_stash_advice.c > +++ b/contrib/pg_stash_advice/pg_stash_advice.c > ... > @@ -464,6 +522,43 @@ pgsa_drop_stash(char *stash_name) > } > } > dshash_seq_term(&iterator); > + > + /* Bump change count. */ > + pg_atomic_add_fetch_u64(&pgsa_state->change_count, 1); > +} > + > +/* > + * Remove all stashes and entries from shared memory. > + * > + * This is intended to be called before reloading from a dump file, so t= hat > + * a failed previous attempt doesn't leave stale data behind. > + */ > +void > +pgsa_reset_all_stashes(void) > +{ I think this might be good to expose on the SQL level as well - in case someone accidentally created a lot of stashes it could be tedious to remove them all, e.g. if they wanted to clear all the memory after an experiment. > diff --git a/contrib/pg_stash_advice/stashpersist.c b/contrib/pg_stash_ad= vice/stashpersist.c > new file mode 100644 > index 00000000000..da96ee0d803 > --- /dev/null > +++ b/contrib/pg_stash_advice/stashpersist.c >... > + /* Parse the query ID. */ > + errno =3D 0; > + queryId =3D strtoll(queryid_str, &endptr, 10); > + if (*endptr !=3D '\0' || errno !=3D 0 || queryid_str =3D=3D = endptr) > + ereport(ERROR, > + (errcode(ERRCODE_DATA_CORRUPTED), > + errmsg("syntax error in file \"%s\" line %u: in= valid query ID \"%s\"", > + PGSA_DUMP_FILE, lineno, queryid_str))); > + It might be worth adding a queryId =3D=3D 0 check here, since we won't check it later, and its helpful to avoid unpredictable behavior just in case someone decided to mess with the file manually. Thanks, Lukas --=20 Lukas Fittl