Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1snhHU-005Rre-37 for pgsql-bugs@arkaria.postgresql.org; Mon, 09 Sep 2024 16:30:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1snhHT-00F7Zw-Pv for pgsql-bugs@arkaria.postgresql.org; Mon, 09 Sep 2024 16:30:23 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1snhGq-00F4wN-8s for pgsql-bugs@lists.postgresql.org; Mon, 09 Sep 2024 16:29:44 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1snhGn-000KQi-7U for pgsql-bugs@lists.postgresql.org; Mon, 09 Sep 2024 16:29:43 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 489GTeRh3208239; Mon, 9 Sep 2024 12:29:40 -0400 From: Tom Lane To: sanskar@flintk12.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18607: UNION ALL discards all foreign key relations + indexes In-reply-to: <18607-651aa996c1e71d48@postgresql.org> References: <18607-651aa996c1e71d48@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Mon, 09 Sep 2024 15:16:33 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3208237.1725899380.1@sss.pgh.pa.us> Date: Mon, 09 Sep 2024 12:29:40 -0400 Message-ID: <3208238.1725899380@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > CREATE OR REPLACE VIEW v3.temp_view AS > SELECT * FROM users WHERE id = 'e-1' > UNION ALL > SELECT * FROM users WHERE id = 'e-2'; > Either way when the view is created, the indexes and the related relations > of the foreign key references are being dropped. Views do not have either indexes or foreign keys. > 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! This seems to be a performance complaint, rather than a valid bug report. You might find it helpful to read https://wiki.postgresql.org/wiki/Slow_Query_Questions regards, tom lane