BUG #18607: UNION ALL discards all foreign key relations + indexes - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #18607: UNION ALL discards all foreign key relations + indexes
Date
Msg-id 18607-651aa996c1e71d48@postgresql.org
Whole thread Raw
Responses Re: BUG #18607: UNION ALL discards all foreign key relations + indexes
Re: BUG #18607: UNION ALL discards all foreign key relations + indexes
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      18607
Logged by:          Sanskar Agrawal
Email address:      sanskar@flintk12.com
PostgreSQL version: 15.0
Operating system:   MacOS
Description:

Min Reproducable env :

Consider the query below -> 

"
CREATE OR REPLACE VIEW v3.temp_view AS
SELECT * FROM users WHERE id = 'e-1'
UNION ALL
SELECT * FROM users WHERE id = 'e-2';
"

groups.id is a primary key and has a unique index defined on the same.

Either way when the view is created, the indexes and the related relations
of the foreign key references are being dropped. 
(Same with "UNION").

What + Why? I am processing the result of the union in another CTE which now
is not having access to indices and so it is performing a seq scan!


pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #18606: syntax error at or near "ROWS"
Next
From: Tom Lane
Date:
Subject: Re: BUG #18607: UNION ALL discards all foreign key relations + indexes