Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 27D8A47592C for ; Tue, 19 Nov 2002 13:52:13 -0500 (EST) Received: from web13802.mail.yahoo.com (web13802.mail.yahoo.com [216.136.175.12]) by postgresql.org (Postfix) with SMTP id 4DFF74758F1 for ; Tue, 19 Nov 2002 13:52:12 -0500 (EST) Message-ID: <20021119182940.91495.qmail@web13802.mail.yahoo.com> Received: from [216.173.173.66] by web13802.mail.yahoo.com via HTTP; Tue, 19 Nov 2002 10:29:40 PST Date: Tue, 19 Nov 2002 10:29:40 -0800 (PST) From: Chris Gamache Reply-To: cgg007@yahoo.com Subject: Using VIEW to simplify code... To: pgsql-sql@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/284 X-Sequence-Number: 10426 Right now I dynamicly generate the SQL for an incredibly ugly 4 table join based on user information client-side. I got the bright idea to create a view and then run a MUUUCH simpler client-side query on that view. The problem is that PostgreSQL apparantly runs the view FIRST and then applies the criteria AFTER assembling the whole view. I was hoping that it would rewrite the "select" in the view to include the criteria BEFORE running the view. That way it could take advantage of the indexes the way my giant-and-hard-to-maintain-client-generated-sql does. Any thoughts or suggestions? If you MUST have the giant-and-hard-to-maintain-client-generated-sql statement and its related explain, I'll produce it. I cringe at the thought of having to redact that monster, tho. CG __________________________________________________ Do you Yahoo!? Yahoo! Web Hosting - Let the expert host your site http://webhosting.yahoo.com