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

From: Christophe Pettus <xof(at)thebuild(dot)com>
To: pgsql-performance(at)lists(dot)postgresql(dot)org
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Jan Wieck <jan(at)wi3ck(dot)info>, "Dean Gibson (DB Administrator)" <postgresql(at)mailpen(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>
Subject: Re: AWS forcing PG upgrade from v9.6 a disaster
Date: 2021-05-29 02:43:23
Message-ID: E007EEB7-097D-4D0E-9C4D-C8BB28810E7F@thebuild.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-performance

> On May 28, 2021, at 14:30, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> I think it uses pg_upgrade.

It does. It does not, however, do the vacuum analyze step afterwards. A VACUUM (FULL, ANALYZE) should take care of that, and I believe the OP said he had done that after the pg_upgrade.

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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2021-05-29 02:56:39 Re: Skipping logical replication transactions on subscriber side
Previous Message Andrew Dunstan 2021-05-29 02:41:08 Re: AWS forcing PG upgrade from v9.6 a disaster

Browse pgsql-performance by date

  From Date Subject
Next Message Dean Gibson (DB Administrator) 2021-05-29 04:08:28 Re: AWS forcing PG upgrade from v9.6 a disaster
Previous Message Andrew Dunstan 2021-05-29 02:41:08 Re: AWS forcing PG upgrade from v9.6 a disaster