> 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