-
Notifications
You must be signed in to change notification settings - Fork 898
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
DISTINCT ON queries return incorrect results on Distributed Hypertables #3784
Comments
The query with DISTINCT on distributed hypertable errors out for me. TS 2.5 & PG 13.14, maybe because I'm using a debug version. |
One of the conditions seems to be that the planner were able to prove that
|
After working around the error message, we still don't always get the correct result:
The plan is incorrect. DISTINCT ON is pushed down to data nodes, but the ORDER BY is not, which is why it gives undetermined results.
|
Previously, we would push DISTINCT ON down to the data nodes even when the pathkeys of the resulting paths on the data nodes were not compatible with the given DISTINCT ON columns. This commit disables pushdown when the sorting is not compatible. Fixes timescale#3784
Previously, we would push DISTINCT ON down to the data nodes even when the pathkeys of the resulting paths on the data nodes were not compatible with the given DISTINCT ON columns. This commit disables pushdown when the sorting is not compatible. Fixes timescale#3784
Previously, we would push DISTINCT ON down to the data nodes even when the pathkeys of the resulting paths on the data nodes were not compatible with the given DISTINCT ON columns. This commit disables pushdown when the sorting is not compatible. Fixes #3784
Previously, we would push DISTINCT ON down to the data nodes even when the pathkeys of the resulting paths on the data nodes were not compatible with the given DISTINCT ON columns. This commit disables pushdown when the sorting is not compatible. Fixes #3784
Relevant system information:
postgres --version
):PostgreSQL 13.4 (Ubuntu 13.4-4.pgdg21.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 10.3.0-1ubuntu1) 10.3.0, 64-bit
\dx
inpsql
): 2.5.0Describe the bug
When issuing DISTINCT ON queries with an ORDER BY against a distributed hypertable, it produces an incorrect result.
When reformatting the same query to do a LIMIT 1, it returns the correct query.
To Reproduce
Steps to reproduce the behavior:
On a multi-node system (Mine has 1 AN and 3 DNs):
I was not able to reproduce this with a small amount of data, so here is a CSV of 100,000 rows which reliably reproduces the incorrect behavior.
distinct_on_repro.csv
Create two identical tables. Make one distributed, one a regular hypertable:
Import the CSV above into both tables.
You can observe the different results with these queries:
Expected behavior
These queries would all return the same row.
Actual behavior
A different row is returned for the DISTINTCT ON query against the distributed hypertable
The text was updated successfully, but these errors were encountered: