Received: from consumercontact.com ([209.167.202.12]) by hub.org (8.9.3/8.9.3) with ESMTP id TAA38195 for ; Tue, 4 Jan 2000 19:09:53 -0500 (EST) (envelope-from rick@consumercontact.com) Received: from consumercontact.com ([192.168.1.54]) by consumercontact.com (8.8.7/8.8.7) with ESMTP id TAA31217 for ; Tue, 4 Jan 2000 19:09:23 -0500 Message-ID: <38728CE2.C1756D3E@consumercontact.com> Date: Tue, 04 Jan 2000 19:14:26 -0500 From: Rick Delaney X-Mailer: Mozilla 4.61 [en] (Win95; U) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Calculation dependencies in views Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I have a table with, say, a dozen fields and I want to end up with a view with around 50 fields, calculated from the original dozen. So it would be something like this: CREATE VIEW final AS SELECT x, y, z, (x + y) as a, (y + z) as b, (x + y) * z as c, (y + z) * x as d, (x + y) * z + x as e, (y + z) * x + x as f FROM my_table; except my expressions are longer and more complicated. However, my expressions do have similar dependencies and redundancies. My question is what is a good way of dealing with this? I was going to do something like CREATE VIEW one AS SELECT id, (x + y) as a, (y + z) as b, FROM my_table; CREATE VIEW two AS SELECT m.id, o.a * m.z as c, o.b * m.x as d, FROM my_table m, one o WHERE m.id = o.id; etc. but I'll end up with a lot of levels and joins going this route which I expect will be pretty slow. Can someone recommend anything to me? Should I be approaching this from a completely different angle i.e other than views? I'm pretty new at this so any pointers will be appreciated. --Rick