Same issue and took us ages to work out that is was JIT! The default is on, and setting off solves the problem. I have seen several blogs reporting the same and so wonder why this default is on?
Z
From: Олександр Янін <aleksandr.janin@privatbank.ua> Sent: Monday, April 22, 2024 8:01 PM To: Johnathan Tiamoh <johnathantiamoh@gmail.com> Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org> Subject: Re: Performance degradation after upgrading from 9.5 to 14
CAUTION: This email originated from outside of the organisation. Do not click links or open attachments unless you recognise the sender and know the content is safe. Visit the information security portal (MetaCompliance - MyCompliance Cloud) to do your training.
Try setting enable_memoize to off. Our practice has shown that enabling this parameter by default often resulted in less than optimal query plans in the cache.