Skip to content
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

Postgres 16.4 bug #110

Open
ngkame opened this issue Oct 15, 2024 · 0 comments
Open

Postgres 16.4 bug #110

ngkame opened this issue Oct 15, 2024 · 0 comments

Comments

@ngkame
Copy link

ngkame commented Oct 15, 2024

Description:
We are experiencing a bug related to PostgreSQL when using Foreign Data Wrapper (FDW) tables that query ClickHouse. Specifically, when executing a query that includes a FDW table (e.g., ch_views.trds), if the query in the WITH clause takes longer than 20 seconds, it enters a cyclic retry loop.

How to Reproduce:
The issue can be reproduced with the following SQL query:

WITH trds AS (
    SELECT * FROM ch_views.trds
)
SELECT * FROM trds
INNER JOIN (
    SELECT *
    FROM views.some_dict
) dict_tbl USING (k_login);

If the query in the trds CTE takes longer than 20 seconds to execute, it results in a retry loop.

Proposed Solutions:

  1. Create a Materialized View:
    To mitigate this issue, we can create a materialized view as follows:

    CREATE MATERIALIZED VIEW ch_views.trds_mv AS
    SELECT * FROM ch_views.trds;

    This materialized view can be refreshed as needed, which may help avoid the timeout issue.

  2. Avoid Using FDW Tables in the WITH Clause:
    Alternatively, we can avoid placing FDW tables in the WITH clause. When the FDW table is not included in the WITH block, the query seems to execute normally without entering the retry loop.

Please let me know if you need any more information or if there are any updates regarding this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant