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 1vfJFN-000rKF-0t for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Jan 2026 14:50:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vfJFL-000gN7-0y for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Jan 2026 14:50:19 +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 1vfJFL-000gMx-02 for pgsql-hackers@lists.postgresql.org; Mon, 12 Jan 2026 14:50:19 +0000 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vfJFI-0002Jg-1J for pgsql-hackers@lists.postgresql.org; Mon, 12 Jan 2026 14:50:18 +0000 Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-64b9cb94ff5so9355109a12.2 for ; Mon, 12 Jan 2026 06:50:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768229416; x=1768834216; 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=mEmCLJyCHYi9uqJCAoULIn4Rqj7ZMOIJUTSa/MAiShM=; b=cLvwB3ymKgWm7G1c62bCl3pOVDyjPAkIHG/Y6dc1nUa9v2ss9/x0hsGGZY8pEv84Tq iZNVK2wYjpHU12WAkcLWFWG7H4Yk5++V4eeyhlhCd0bTauRTd4Vm1GrWIC2c9EW21Jmy hkzTlaaRtwbnb1Nw1gzICsoztCzShOI9/nxr2omhR4sXUE+hIEy3ICzazeJ5LZW9L5u8 igM/Jb+VBTZzwaTNybVVkCcQoY09XMHgmNMe+g/2zL9z73U90tDhHcZAW/VQwPmZNhXf T6YyhN8lz4YpT8ctwsRuGY6ey3/HriWqtZzOIdmKBZPQub0d2ed14laH86BiAsIfvqT6 TooQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768229416; x=1768834216; 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=mEmCLJyCHYi9uqJCAoULIn4Rqj7ZMOIJUTSa/MAiShM=; b=TxO22+v6/T4fht3IwAUrWMcq9TzPpmZ0nxtSTbTUk5Et0noAWtg8mV1DQC3K8RB2t3 N8dUMf/Njta0MOdJIgRXMvRZAbGT9f6lRZ6G3ndb5N2idGsM3DXqDrJII6O57JgUJ62x hUL9L3vvCXxYP8q3NmtIJwqWX3PIzlh/AmwQiAEdcc+h6VInxn+W4R/0xdq+R+T2ih73 +VSEKCfL6DmMRv3y8lv0gknyMkdRcdLDfEylvxk5B01+3Mbe15NwL5KDNNFXh7HyElTC Dm2heqlybyFYFN15DUhSESjYkzwCdd+8cmc+yvk/5wNQV5jezNSJUpRhd6tqlbu9hRru Ib5Q== X-Forwarded-Encrypted: i=1; AJvYcCUNjI946BGT4DxiOj/KffsZ7PEoBrQhCgS0A+Op2QTCa1EIzW5eNMTtzqRM9F8TYpixyRr5k1yO1Kw/yVNy@lists.postgresql.org X-Gm-Message-State: AOJu0Yzy7xtmPCvsrkUnmUk9Y/i1IhJqoXVEZ+JYs9UTuRUJOicB1MDl dP2TpZ+lEQva3Yv3784AMgUhawOWtoS9bOUdUGZCWnmmRb3I1zc6v8XlFbIPM9hn293TZviGGBJ ruv2YBBa/p6kX9Amb5r5HTlLcV/bpQX0= X-Gm-Gg: AY/fxX6ze0fURRgkxjdfnlNexGrI5kLcj3Dd8zDkxc3WrkUuAmE+ncDXuxwaxO73t9u 6VFCpnXsAyxCB2U+H8fXf7k/d8YE5QNhSb/INVNJ9neHL9+P7+YfFoJEdgu5jh2YDxxWYJdo9xL 1UzBwnGG6F+6GjTTCo4NjTGQacSwilORYDKiDpKqvEz7Zwv8RbyGxwIuV7G8BFxuou5busMXnMn UtKta4GmlaifBUSYErf+a63xxSWm4F/zxs79GkepozljuSZ5YAWSIqTLcAYAuL/TrruhQiVo7Y0 VAQHZGLD5CCqZtoycDSMUoQvC+k= X-Google-Smtp-Source: AGHT+IFOl2MEvqQ3nTaUvAzGdLR7OJ2EEKDXmmQb09TcdXxkYAD6LIM3AwYKQx4+uVwQIytyCen8NYYP5hP+fT3cNRs= X-Received: by 2002:a17:906:6a1c:b0:b87:3396:d152 with SMTP id a640c23a62f3a-b873396d1a0mr13447466b.15.1768229414995; Mon, 12 Jan 2026 06:50:14 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Robert Haas Date: Mon, 12 Jan 2026 09:50:03 -0500 X-Gm-Features: AZwV_QjJ7ZTQAaLdnA925yD_q6WFakHxohH_9VQ2ixXOgPrupDqMOxylwwjIhgU Message-ID: Subject: Re: pg_plan_advice To: Michael Paquier Cc: Lukas Fittl , Jacob Champion , Dian Fay , Matheus Alcantara , 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 Thu, Jan 8, 2026 at 6:29=E2=80=AFPM Michael Paquier wrote: > So you are telling me that I can commit code that deletes code. Count > me in. The project has some merge requests that I've been holding on > a bit due to what's happening here and because I did not really look > at the internals that have changed. It's great to see that you have > begun an investigation, Lukas. :-) > I suspect that this is going to be an incremental integration process, > and it smells to me that it is going to require more than one major > release before being able to remove the whole set of hacks that > pg_hint_plan has been using, particularly with the GUCs, the costing > and the forced update of the backend routines which is a ugly > historical hack. Saying that, I would need to look at the plan > outputs to be sure, perhaps we would be OK even with slight changes. > These happen every year, because the plans tested are complex enough > that some of the sub-paths are changed, but the hints still work > properly. This year for v19 we have at least the changes in the > expression names. I think it's quite possible that you could do a full rip and replace with some study of what needs to be added on top of 0004. The core idea of 0004 is that it adds a field called pgs_mask in several of places, which allows you to set a bitmask to control which operations the planner will consider to be enabled. You can set this via some existing hooks, and it also adds a a new hook (joinrel_setup_hook) which is called near the start of add_paths_to_joinrel(). So, you can set pgs_mask in PlannerGlobal to control planning for the entire operation, RelOptInfo to control it for a particular rel, or JoinPathExtraData to set it for a particular joinrel and a particular choice of outer and inner rel. I am pretty well convinced that this is a good model: instead of duplicating a bunch of planner code, as pg_hint_plan currently does, just have a way to tell the existing planner code what you want it to do. Now, one fly in the ointment is that pgs_mask is just a mask -- that is, it gives us space to store 64 related Booleans, but nothing else. So if we want to store an integer, like a number of parallel workers, we need a separate field for that. But if that integer can reasonably be set at the same levels that are possible for pgs_mask, it's really easy: just look at the places where 0004 adds a pgs_mask field, and add an integer field as well. There is obviously some limit to the number of fields we can reasonably add to PlannerGlobal, RelOptInfo, and JoinPathExtraData, but if it starts to become too much, we could bundle some or all of them up in a struct. The patch has already figured out how to get the mask to propagate down to the places where low-level planning decisions are being made, so it seems worth trying to piggy-back on that for anything else that we need. Now, maybe that won't work out for some reason. But on the other hand, maybe it will work out. I think it's possible that for the price of a quite small patch adding another field or a couple of fields on top of pgs_mask and in the same places, you could get rid of a lot more code. --=20 Robert Haas EDB: http://www.enterprisedb.com