X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 1CA2AD1B545 for ; Wed, 1 Oct 2003 13:06:33 +0000 (GMT) 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 27807-03 for ; Wed, 1 Oct 2003 10:05:46 -0300 (ADT) Received: from ns1.bee.lt (ns.bi.lt [213.226.131.131]) by svr1.postgresql.org (Postfix) with ESMTP id 8E82FD1B540 for ; Wed, 1 Oct 2003 10:05:42 -0300 (ADT) Received: from B027543 (inet.bee.lt [213.226.131.30]) by ns1.bee.lt (8.11.6/8.11.6) with SMTP id h91D5jf01404 for ; Wed, 1 Oct 2003 16:05:45 +0300 Message-ID: <085401c3881c$bacfaca0$f20214ac@bite.lt> From: "Mindaugas Riauba" To: References: <07c001c38815$29277b90$f20214ac@bite.lt> <200310011339.01707.dev@archonet.com> Subject: Re: What is the fastest null WHERE Date: Wed, 1 Oct 2003 16:05:41 +0300 MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1257" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/14 X-Sequence-Number: 3762 > > While writing web application I found that it would > > be very nice for me to have "null" WHERE clause. Like > > WHERE 1=1. Then it is easy to concat additional > > conditions just using $query . " AND col=false" syntax. > > > > But which of the possible "null" clauses is the fastest > > one? > > I suspect WHERE true, but is it really necessary. Thanks. I'll use "WHERE true" for now. And of course it is not necessary it just simplifies code a bit. > Most languages will have a join() operator that lets you do something like: > > $where_cond = join(' AND ', @list_of_tests) That's not the case. Test may or may not be performed based on web form values. Mindaugas