Re: Postgres: Queries are too slow after upgrading to PG17 from PG15
От | Peter Geoghegan |
---|---|
Тема | Re: Postgres: Queries are too slow after upgrading to PG17 from PG15 |
Дата | |
Msg-id | CAH2-WzmNhY2HWNkPku0ugesSp=AxWyy+9tCaq4YqNMSRV8QDqw@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Postgres: Queries are too slow after upgrading to PG17 from PG15 (Sajith Prabhakar Shetty <ssajith@blackduck.com>) |
Ответы |
Re: Postgres: Queries are too slow after upgrading to PG17 from PG15
Re: Postgres: Queries are too slow after upgrading to PG17 from PG15 |
Список | pgsql-bugs |
On Tue, Jul 29, 2025 at 1:49 AM Sajith Prabhakar Shetty <ssajith@blackduck.com> wrote: > I understand you have found out the root cause I wouldn't say that -- it isn't clear that this issue with qsorting during preprocessing is the root cause. As I said, it is (at a minimum) the immediate problem with your query. But the underlying code path didn't change all that much in Postgres 17 -- it just started to be hit a lot more with this particular query. This is more or less a consequence of the fact that the new-to-17 query plan has an inner index scan with an inconvenient combination of 2 things: it is very selective and fast (fast per individual execution), even though it has a couple of SAOPs (a SAOP is an = ANY() condition) that each have several hundred array elements. That's what allows these startup costs (i.e. array preprocessing that does these 2 qsorts on each execution) to dominate so much. My Postgres 17 commit 5bf748b8 made the planner stop generating distinct index paths that make lower-order SAOPs into "Filter:" conditions, which are executed outside of the core B-Tree code, using a completely different code path. Those index paths are used by the Postgres 15 plan. I am very hesitant to add anything like that back, though, because they're very unlikely to be faster than an index path that makes the executor push down the SAOP condition into the B-Tree code (your counterexample notwithstanding). Perhaps Tom can weigh-in here. I removed code that generated these alternative index paths from the planner because its original justification (see bugfix commit a4523c5a, a follow-up to bugfix commit 807a40c5) no longer applied. Perhaps this should be revisited now, or perhaps the issue should be ameliorated on the nbtree side. Or maybe we should just do nothing -- the issue can be worked around in the application itself. -- Peter Geoghegan
В списке pgsql-bugs по дате отправления: