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 1vL0sZ-000SnR-2Y for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Nov 2025 15:10:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vL0rZ-000O7t-1J for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Nov 2025 15:09:53 +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 1vL0rZ-000O7l-0O for pgsql-hackers@lists.postgresql.org; Mon, 17 Nov 2025 15:09:53 +0000 Received: from mail-yw1-x112c.google.com ([2607:f8b0:4864:20::112c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vL0rX-0000wU-0b for pgsql-hackers@lists.postgresql.org; Mon, 17 Nov 2025 15:09:52 +0000 Received: by mail-yw1-x112c.google.com with SMTP id 00721157ae682-787da30c50fso39708137b3.3 for ; Mon, 17 Nov 2025 07:09:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763392189; x=1763996989; 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=K2CTG6kuBkHOvQH3aaZefgywOHgCM/D2ylPPNzX6VEY=; b=GOx4HeeqwmjbCmDenP0/9ehbfXFeq8b2y8Wz3uwGSMDGEigCVKdpnJcOSJDu5Z4isv j0NiZXRdhdCnCGD9XGAkX6+6va5lK5vV+mNUC4y0IjUOYcsIn2/YAjQtexvWMinf6muv nlbxObJdj2HlbAgi+ixozYkU2nNLeTaQ4O0E1ZpFsm3kF0D6hP3GxjXFZ3qpqXZoY7E1 Hve9IDE7MZqXY+qrpZ3SHPjN1qm76kkZiZGMwvNwFs5MU7cixLmlrCld12DqpB41g2l4 tlxUvyIJ/i7nHy8ssqzbW2nqdsXh7u9usEa4w84lHQco6iK24N7t3RXFmd0eQIKchipn Kmyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763392189; x=1763996989; 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=K2CTG6kuBkHOvQH3aaZefgywOHgCM/D2ylPPNzX6VEY=; b=u4My1I1yJX9DmeRbbzgzwJ0js+XXnrR5aL2iva9hg470HWJME7gmInVGdWAqaWUuC0 wFkFodfs69cCM195fkSKj0GNjoLFnj2eKWI8AyohJE4R703P2lAyBM7x9iS7X1miBJFO YjxnvSM3w/fmkLCY4cPqzJbuP07aMbgMqaqAKap4eByerhESZ9i08zLd2kOUIpK7+pDs 9GUDwpcKtVjGonhTWnPn72IsVAGQdFm2oMNwpl5MmUvrZaU2E9wqAyCC/DyDETzU17/5 HUY60KBoYc3S4rmsD+47skSsZR+TQ4GislcMcLLASp1mxYXX911S6UcCIC34q7T0D3DU YDOg== X-Forwarded-Encrypted: i=1; AJvYcCVX98IOvGqY5YKJBt8OyPsegHuioIyO4sLyOc9TvxopFTiCRMw+AAXzr8Un4vP6R2Z7wTFRpgJRHgb2xsyu@lists.postgresql.org X-Gm-Message-State: AOJu0Yx4g7O3Dk3u2N2EMZpOJ5Z6fS0PnrwCHTF2ODBSBFDET77QXBGK SRhRwGyDPHO+0uGPR/vteY/td7s8lW52UEvyI7AvvAz2PFxDSmA/EaoFwXelAgvUNVDeGhfMtUl u37J32Vztpo3N6AW2XHHPH0OlyGRq6PE= X-Gm-Gg: ASbGnctj5CRsMtYberFwGCsqiEM3khqrCdKx2UK7kLg2ZJucwPPj5b4J2l88T36F+/Q Pr2oq8d2io6VNh3Qp28lWj2qrRlY0BHax/Cy7e3OSJI3VTxIGLcSQd/Jp+anAP0XStI+GWDUHCF w89bgIzhChYIqugnqmlSnZGev4RzGBvsK7MEuoi+EEOvBJL7kH/M+B7gXqyB7slBKao4GRZPoy9 prk31P8i/NrT7M9IbnC035lnOZ+O7t/61IDdjAW2g6awqOVKxt1JB8vQouh38meuzp05TKICRsb WFqN6SzuDFzouv850eDXdzqFRdqkBw== X-Google-Smtp-Source: AGHT+IF1qc3QZtPxR//CAAbItS6kakrHO38KC8S0dm37W8REdcWtTydWQJFwlEoC3HqtMD6W9Ojx27p/0rAa/p/BSSk= X-Received: by 2002:a05:690c:e3c7:b0:781:64f:2b1a with SMTP id 00721157ae682-78929f1b227mr231355937b3.60.1763392189125; Mon, 17 Nov 2025 07:09:49 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Robert Haas Date: Mon, 17 Nov 2025 10:09:36 -0500 X-Gm-Features: AWmQ_bmMOWoYx7HspDnHLkJoN5w6RNDX8UTrwrkYPNiTVj0nxfJFUhKX_XXPGb4 Message-ID: Subject: Re: pg_plan_advice To: Matheus Alcantara Cc: Jakub Wartak , 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 Mon, Nov 17, 2025 at 9:42=E2=80=AFAM Matheus Alcantara wrote: > I've spent some time playing with these patches. I still don't have to > much comments on the syntax yet but I've noticed a small bug or perhaps > I'm missing something? Cool, thanks for looking. I am guessing that the paucity of feedback thus far is partly because there's a lot of stuff to absorb -- though the main point at this stage is really to get some opinions on the planner infrastructure/hooks, which don't necessarily require full understanding of (never mind agreement with) the design of pg_plan_advice itself. > When I run CREATE EXTENSION pg_plan_advice I'm able to use the > EXPLAIN(plan_advice) but if try to open another connection, with the > extension already previously created, I'm unable to use once I drop and > re-create the extension. This is just an idiosyncrasy of PostgreSQL's extension framework. Whether or not EXPLAIN (PLAN_ADVICE) works depends on whether the shared module has been loaded, not whether the extension has been created. The purpose of CREATE EXTENSION is to put SQL objects, such as function definitions, into the database, but there's no SQL required to enable EXPLAIN (PLAN_ADVICE) -- or for setting the pg_plan_advice.advice GUC. However, running CREATE EXTENSION to establish the function definitions will incidentally load the shared module into that particular session. Therefore, the best way to use this module is to add pg_plan_advice to shared_preload_libraries. Alternatively, you can use session_preload_libraries or run LOAD in an individual session. If you don't care about the collector interface, that's really all you need. If you do care about the collector interface, then in addition you will need to run CREATE EXTENSION, so that the SQL functions needed to access it are available. --=20 Robert Haas EDB: http://www.enterprisedb.com