Re: AWS forcing PG upgrade from v9.6 a disaster

From: "Dean Gibson (DB Administrator)" <postgresql(at)mailpen(dot)com>
To: pgsql-performance(at)lists(dot)postgresql(dot)org
Subject: Re: AWS forcing PG upgrade from v9.6 a disaster
Date: 2021-05-29 04:08:28
Message-ID: cf15c19d-43d8-95ff-17a0-ded099f70861@mailpen.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-performance

On 2021-05-28 19:43, Christophe Pettus wrote:
> ...
> The most common reason for this kind of inexplicable stuff after an RDS upgrade is, as others have said, parameter changes, since you get a new default parameter group after the upgrade.
>
> That being said, this does look like something happened to the planner to cause it to pick a worse plan in v13. The deeply nested views make it kind of hard to pin down, but the core issue appears to be in the "good" plan, it evaluates the _Club.club_count > 5 relatively early, which greatly limits the number of rows that it handles elsewhere in the query. Why the plan change, I can't say.
>
> It might be worth creating a materialized CTE that grabs the "club_count > 5" set and uses that, instead of having it at the top level predicates.

I spent quite a bit of time over the past five days experimenting with
various parameter values, to no avail, but I don't mind trying some more.

I have other queries that fail even more spectacularly, & they all seem
to involve a generated table like the "club" one in my example.  I have
an idea that I might try, in effectively changing the order of
evaluation.  I'll have to think about that.  Thanks for the suggestion! 
However, one "shouldn't" have to tinker with the order of stuff in SQL; 
that's one of the beauties of the language: the "compiler" (planner) is
supposed to figure that all out.  And for me, that's been true for the
past 15 years with PostgreSQL.

Note that this problem is not unique to v13.  It happened with upgrades
to v10, 11, &12.  So, some fundamental change was made back then (at
least in the RDS version).  Since I need a bulletproof backup past next
January, I think my next task will be to get an EC2 instance running
v9.6, where AWS can't try to upgrade it.  Then, at my leisure, I can
fiddle with upgrading.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2021-05-29 04:16:35 Re: Parallel Inserts in CREATE TABLE AS
Previous Message Andy Fan 2021-05-29 03:23:31 Regarding the necessity of RelationGetNumberOfBlocks for every rescan / bitmap heap scan.

Browse pgsql-performance by date

  From Date Subject
Next Message Alexey M Boltenkov 2021-05-29 05:24:37 Re: AWS forcing PG upgrade from v9.6 a disaster
Previous Message Christophe Pettus 2021-05-29 02:43:23 Re: AWS forcing PG upgrade from v9.6 a disaster