Errors "failed to construct the join relation" and "failed to build any 2-way joins"
Will Leinweber <will@bitfission.com>
From: Will Leinweber <will@bitfission.com>
To: pgsql-hackers@lists.postgresql.org
Date: 2019-12-12T23:32:05Z
Lists: pgsql-hackers
On 12.1, fresh initdb the following query gives me the error
"ERROR: failed to construct the join relation"
SELECT FROM (
SELECT FROM pg_catalog.pg_stat_bgwriter AS ref_0
LEFT JOIN pg_catalog.pg_stat_bgwriter AS ref_1 ON (true), LATERAL (
SELECT FROM pg_catalog.pg_publication AS ref_2, LATERAL (
SELECT FROM pg_catalog.pg_class
WHERE ref_1.buffers_alloc IS NOT NULL
) AS subq_0
WHERE true
LIMIT 1
) AS subq_1
WHERE true
) AS subq_2
If you move the limit up into subq_0, then the error changes to
"ERROR: failed to build any 2-way joins"
SELECT FROM (
SELECT FROM pg_catalog.pg_stat_bgwriter AS ref_0
LEFT JOIN pg_catalog.pg_stat_bgwriter AS ref_1 ON (true), LATERAL (
SELECT FROM pg_catalog.pg_publication AS ref_2, LATERAL (
SELECT FROM pg_catalog.pg_class
WHERE ref_1.buffers_alloc IS NOT NULL
LIMIT 1
) AS subq_0
WHERE true
) AS subq_1
WHERE true
) AS subq_2
I'm unable to reproduce either of the errors on 11.6 or 11.4. I haven't tried
any other versions. The actual value of the limit doesn't appear to matter,
just if it's present or not.
— Will
Commits
-
Prevent overly-aggressive collapsing of joins to RTE_RESULT relations.
- d04e2553d49d 12.2 landed
- 6ea364e7e7d5 13.0 landed