Re: pg_plan_advice
| От | Robert Haas |
|---|---|
| Тема | Re: pg_plan_advice |
| Дата | |
| Msg-id | CA+TgmoZf1F360z6jNVZyv7UF=URSNvCWbsCX7A_nsH=iaEqm0A@mail.gmail.com обсуждение исходный текст |
| Ответ на | Re: pg_plan_advice (Jakub Wartak <jakub.wartak@enterprisedb.com>) |
| Ответы |
Re: pg_plan_advice
|
| Список | pgsql-hackers |
On Fri, Oct 31, 2025 at 5:59 AM Jakub Wartak <jakub.wartak@enterprisedb.com> wrote: > > First, any form of user control over the planner tends to be a lightning rod for criticism around here. > > I do not know where this is coming from, but everybody I've talked to > was saying this is needed to handle real enterprise databases and > applications. I just really love it, how one could precisely adjust > the plan with this even with the presence of heavy aliasing: Thanks for the kind words. I'll respond to the points about compiler warnings later. > To attract a little attention to the $thread, the only bigger design > (usability) question that keeps ringing in my head is how we are going > to bind it to specific queries without even issuing any SETs(or ALTER > USER) in the far future in the grand scheme of things. The discussed > query id (hash), full query text comparison, maybe even strstr(query , > "partial hit") or regex all seem to be kind too limited in terms of > what crazy ORMs can come up with (each query will be potentially > slightly different, but if optimizer reference points are stable that > should nail it good enough, but just enabling it for the very specific > set of queries and not the others [with same aliases] is some major > challenge). Yeah, I haven't really dealt with this problem yet. > Due to this, at some point I was even thinking about some hashes for > every plan node (including hashes of subplans), [...] > > and then having a way to use `somehashval3` (let's say it's SHA1) as a > way to activate the necessary advice. Something like having a way to This doesn't make sense to me, because it seems circular. We can't use anything in the plan to choose which advice string to use, because the purpose of the advice string is to influence the choice of plan. In other words, our choice of what advice string to use has to be based on the properties of the query, not the plan. We can implement anything we want to do in terms of exactly how that works: we can use the query ID, or the query text, or the query node tree. Hypothetically, we could call out to a user-defined function and pass the query text or the query node tree as an argument and let it do whatever it wants to decide on an advice string. The practical problem here is computational cost -- any computation that gets performed for every single query is going to have to be pretty cheap to avoid creating a performance problem. That's why I thought matching on query ID or exact matching on query text would likely be the most practical approaches, aside from the obvious alternative of setting and resetting pg_plan_advice.advice manually. But I haven't really explored this area too much yet, because I need to get all the basics working first. -- Robert Haas EDB: http://www.enterprisedb.com
В списке pgsql-hackers по дате отправления: