Re: Strange execution plan - Mailing list pgsql-performance

From Manuel Weitzman
Subject Re: Strange execution plan
Date
Msg-id EE6D94D6-2F72-4B51-9ACE-750230596A54@gmail.com
Whole thread Raw
In response to Re: Strange execution plan  (Manuel Weitzman <manuelweitzman@gmail.com>)
List pgsql-performance

> On 08-07-2021, at 17:13, Manuel Weitzman <manuelweitzman@gmail.com> wrote:
> 
> Option A: Use a common table expression to "force" the usage of
> test_json_data_idx
> 
>    WITH json_matching_rows AS (
>        SELECT t.*
>        FROM test ti
>        WHERE t.json_data @> '{"book":{"title":"In Search of Lost Time"}}'
>    )
>    SELECT t.*
>    FROM json_matching_rows t
>    WHERE  t."existe" IS true
>    ORDER BY t."id" DESC
>    LIMIT 100 OFFSET 0;
> 

The first query line should be
    WITH MATERIALIZED json_matching_rows AS (

I had forgotten that Postgres 12 removed the optimization barrier on
common table expressions.
To introduce it again the MATERIALIZED clause is needed.

Apparently I need to work on reviewing my emails properly before
sending them.


Best regards,
Manuel Weitzman



pgsql-performance by date:

Previous
From: "Mike Sofen"
Date:
Subject: RE: Partition column should be part of PK
Next
From: Nagaraj Raj
Date:
Subject: Re: Partition column should be part of PK