Re: Poor Performance running Django unit tests after upgrading from 10.6

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Roger Hunwicks <roger(at)tonic-solutions(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Poor Performance running Django unit tests after upgrading from 10.6
Date: 2020-10-15 10:59:39
Message-ID: e7db6891-7ce9-aab1-abca-373e94692fd4@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance


On 10/15/20 1:21 AM, Roger Hunwicks wrote:
>
> I think we have narrowed down the problem to a single, very complex,
> materialized view using CTEs; the unit tests create the test data and
> then refresh the materialized view before executing the actual test
> code.
>

Have you checked to see if the CTE query is affected by the change to
how CTEs are run in release 12?

The release notes say:

Allow common table expressions (CTEs) to be inlined into the outer
query (Andreas Karlsson, Andrew Gierth, David Fetter, Tom Lane)

Specifically, CTEs are automatically inlined if they have no
side-effects, are not recursive, and are referenced only once in the
query. Inlining can be prevented by specifying MATERIALIZED, or
forced for multiply-referenced CTEs by specifying NOT MATERIALIZED.
Previously, CTEs were never inlined and were always evaluated before
the rest of the query.

So if you haven't already, start by putting MATERIALIZED before each CTE
clause:

with foo as MATERIALIZED (select ...),

bar as MATERIALIZED  (select ...),

...

and see if that changes anything.

cheers

andrew

--
Andrew Dunstan
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2020-10-15 13:56:12 Re: Poor Performance running Django unit tests after upgrading from 10.6
Previous Message Laurenz Albe 2020-10-15 06:56:47 Re: Poor Performance running Django unit tests after upgrading from 10.6