Re: Poor Performance running Django unit tests after upgrading from 10.6 - Mailing list pgsql-performance

From Andrew Dunstan
Subject Re: Poor Performance running Django unit tests after upgrading from 10.6
Date
Msg-id e7db6891-7ce9-aab1-abca-373e94692fd4@dunslane.net
Whole thread Raw
In response to Poor Performance running Django unit tests after upgrading from 10.6  (Roger Hunwicks <roger@tonic-solutions.com>)
List 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




pgsql-performance by date:

Previous
From: Roger Hunwicks
Date:
Subject: Poor Performance running Django unit tests after upgrading from 10.6
Next
From: Tom Lane
Date:
Subject: Re: Poor Performance running Django unit tests after upgrading from 10.6