-
Notifications
You must be signed in to change notification settings - Fork 891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Using now() selects way more chunks than using timestamp literals when enable_partitionwise_aggregate=on #6059
Comments
Hello @mrksngl, Thanks for the detailed steps to reproduce the issue. In a single-node environment, I see the following query plans:
As you mentioned, as soon as For single-node environments, we plan to include a new feature in Timescale 2.12, which performs partition-wise aggregation and works with optimizations like |
Ok, so it's also postgres deciding to do the replan if In a multinode environment, I've also seen that the list of chunks to be scanned is already included in the query. Just a wild idea, I'm not into that level of detail here ;) |
Fixed by #6065 |
What type of bug is this?
Performance issue
What subsystems and features are affected?
Query planner
What happened?
I executed two queries:
EXPLAIN … SELECT … WHERE time >= now()-'1 month'::timestamp
EXPLAIN … SELECT … WHERE time >= '2023-08-11'::timestamp
When
enable_partitionwise_aggregate=off
, both queries roughly do the same, but withenable_partitionwise_aggregate=on
, the first one usingnow()
scans on chunks which are not applicable for the time range in question.I first encountered this in a multinode setup, but could also reproduce it on a non-distributed scenario, see below.
I guess that this leads to a performance degradation, as a lot more (all?) chunks are scanned by those queries. It is also very visible in a multinode setup, where the array of chunks to be examined is quite long when using
EXPLAIN
.Extra Info:
This has been the root cause for a lot of strange behavior we have encountered lately:
DELETE ... WHERE ... now()
, it also scans on old, i.e. (in our case) compressed chunks, ultimately resulting in errortransparent decompression only supports tableoid system column
although those chunks should have never been touched as of theWHERE
clause. Again it worked when using an absolute timestamp literal in the clause.Again note, that it only happens if
enable_partitionwise_aggregate
ison
. In a multinode setup it is sufficient to enable it on the access node only to provoke the misbehavior.TimescaleDB version affected
2.11.2
PostgreSQL version used
15.4
What operating system did you use?
Official docker image timescale/timescaledb:latest-pg15
What installation method did you use?
Docker
What platform did you run on?
On prem/Self-hosted
Relevant log output and stack trace
No response
How can we reproduce the bug?
The text was updated successfully, but these errors were encountered: