X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id BC9ADD1B94F for ; Wed, 27 Aug 2003 12:52:40 -0300 (ADT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 42756-09 for ; Wed, 27 Aug 2003 12:52:10 -0300 (ADT) Received: from news.hub.org (unknown [64.117.224.194]) by svr1.postgresql.org (Postfix) with ESMTP id C61F0D1B8E4 for ; Wed, 27 Aug 2003 12:52:09 -0300 (ADT) Received: from news.hub.org (host-64-117-224-194.altec1.com [64.117.224.194] (may be forged)) by news.hub.org (8.12.9/8.12.9) with ESMTP id h7RFq9ek012561 for ; Wed, 27 Aug 2003 15:52:09 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h7RFUxVM006534 for pgsql-sql@postgresql.org; Wed, 27 Aug 2003 15:30:59 GMT From: radevenz@ix.netcom.com (Richard A. DeVenezia) X-Newsgroups: comp.databases.postgresql.sql Subject: Q: Multicolumn lookup, Join or Sub-query ? Date: 27 Aug 2003 08:30:24 -0700 Organization: http://groups.google.com/ Lines: 36 Message-ID: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: groups-abuse@google.com To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/337 X-Sequence-Number: 14953 I have a table T with many columns whose values are are lookup keys id_1, id_2, id_3, id_4, id_5, ..., id_26 The values corresponding to the keys live in table L, the lookup table: id, id_value T might have 100K rows and L 500K rows. I am wondering what would be the best view (performance-wise) to see the values? ----- Method one - join create view V1 as select a.id_value as v_1, ... z.id_value as v_26 from T, L as a, L as b, ..., L as z where a.id = T.id_1 and b.id = T.id_2 ... and z.id = T.id_26 ----- Method two - sub-query create view V2 as select (select id_value from L where id = id_1) as v_1 , (select id_value from L where id = id_2) as v_2 ... , (select id_value from L where id = id_26) as v_26 TIA, Richard