public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tom Lane <[email protected]>
To: Miguel Angel Prada <[email protected]>
Cc: [email protected]
Subject: Re: Help with error date_trunc() function.
Date: Fri, 05 Apr 2024 12:37:47 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
Miguel Angel Prada <[email protected]> writes:
> I would need help to know what could be happening to cause the error
> when using the /date_trunc/ function.
EXPLAIN would be informative, but I bet what is happening is that the
date_trunc condition is being pushed down to the scan of pg_class,
since it mentions no variables that aren't available there. Then it
can get evaluated on tables whose names don't match the pattern you
expect. I doubt it's more than luck that PG 15 isn't doing the
same thing.
The usual recommendation for fixing this kind of thing is to insert an
optimization fence to keep the WHERE clause from being pushed down.
You could add "OFFSET 0" in the sub-select, or convert it into a
materialized CTE.
regards, tom lane
view thread (2+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Help with error date_trunc() function.
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox