Received: from wolff.to (wolff.to [66.92.219.49]) by postgresql.org (Postfix) with SMTP id 56E51475931 for ; Wed, 17 Jul 2002 08:00:58 -0400 (EDT) Received: (qmail 5637 invoked by uid 500); 17 Jul 2002 12:06:46 -0000 Date: Wed, 17 Jul 2002 07:06:46 -0500 From: Bruno Wolff III To: Josh Berkus Cc: pgsql-sql@postgresql.org Subject: Re: Indexing UNIONs Message-ID: <20020717120646.GA5520@wolff.to> Mail-Followup-To: Josh Berkus , pgsql-sql@postgresql.org References: <20020716114553.GB29323@wolff.to> <20020716192006.GC32419@wolff.to> <200207161542.23433.josh@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200207161542.23433.josh@agliodbs.com> User-Agent: Mutt/1.3.25i X-Archive-Number: 200207/265 X-Sequence-Number: 8643 On Tue, Jul 16, 2002 at 15:42:23 -0700, Josh Berkus wrote: > > Table "events", the largest table in the database, contains event schedule > listing with 11 attributes and one dependant table as well as recursive > relationships between events. Each event record can be (and Must be) > related to either one Case or one Trial Group. > > Thus, I need to relate (in views and queries) each Event to the Union of Cases > and Trial Groups. I just can't figure out how to do so without the database > discarding the indexes on Cases in the process and things slowing to a crawl. I think you might be able to do this using (one sided) outer joins of the event table to the Case and Trial Group tables. The join rules will need to work for exactly one of the two tables. You probably will want to use case statements in the select list to pick values from the right table.