BUG #18607: UNION ALL discards all foreign key relations + indexes
PG Bug reporting form <noreply@postgresql.org>
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: sanskar@flintk12.com
Date: 2024-09-09T15:16:33Z
Lists: 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!