Re: SELECT query results are different depending on whether table statistics are available.

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: James Brauman <james(dot)brauman(at)envato(dot)com>
Cc: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: SELECT query results are different depending on whether table statistics are available.
Date: 2020-05-28 03:13:47
Message-ID: CAKFQuwZuJfDTD5bnEpNj3Bpd6E2pdMF9jfUVBim+gp_ALmH7Eg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, May 27, 2020 at 8:09 PM James Brauman <james(dot)brauman(at)envato(dot)com>
wrote:

> -- Run select query (involving several CTEs).
> SELECT ...;
>
> I haven't generated a minimal test case yet, but I did notice that if
> all CTEs in the SELECT query are defined using AS NOT MATERIALIZED the
> results are always the same regardless of whether the table has been
> ANALYZED yet.
>
> Could anyone share knowledge about why this is happening?
>

A likely scenario is you are missing an ORDER BY in a location where you
are depending on deterministic row ordering and its changing out from
underneath you.

David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message James Brauman 2020-05-28 03:32:22 Re: SELECT query results are different depending on whether table statistics are available.
Previous Message James Brauman 2020-05-28 03:09:23 SELECT query results are different depending on whether table statistics are available.