BUG #18607: UNION ALL discards all foreign key relations + indexes

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: sanskar(at)flintk12(dot)com
Subject: BUG #18607: UNION ALL discards all foreign key relations + indexes
Date: 2024-09-09 15:16:33
Message-ID: 18607-651aa996c1e71d48@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 18607
Logged by: Sanskar Agrawal
Email address: sanskar(at)flintk12(dot)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!

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2024-09-09 16:29:40 Re: BUG #18607: UNION ALL discards all foreign key relations + indexes
Previous Message Tom Lane 2024-09-09 14:42:46 Re: BUG #18606: syntax error at or near "ROWS"