Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 82318632D2A for ; Wed, 23 Dec 2009 12:36:39 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 35014-09 for ; Wed, 23 Dec 2009 16:36:32 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 034676328A8 for ; Wed, 23 Dec 2009 12:36:31 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id nBNGaVmf028620; Wed, 23 Dec 2009 11:36:31 -0500 (EST) To: Craig Ringer cc: Pavel Stehule , Ivan Sergio Borgonovo , pgsql-sql@postgresql.org Subject: Re: short-cutting if sum()>constant In-reply-to: <4B323F21.3020007@postnewspapers.com.au> References: <20091222133527.3007bd96@dawn.webthatworks.it> <162867790912221147r7e3041fej44332a05faf915d6@mail.gmail.com> <20091223000031.54ad09b5@dawn.webthatworks.it> <20091223010940.51c5c069@dawn.webthatworks.it> <20091223024635.48d66554@dawn.webthatworks.it> <162867790912222338v73261b73u5c4e88a5ce85918f@mail.gmail.com> <20091223115628.1709caf5@dawn.webthatworks.it> <162867790912230352v5b6e395fm1880111c04eaa626@mail.gmail.com> <4B323F21.3020007@postnewspapers.com.au> Comments: In-reply-to Craig Ringer message dated "Thu, 24 Dec 2009 00:02:41 +0800" Date: Wed, 23 Dec 2009 11:36:31 -0500 Message-ID: <28619.1261586191@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200912/79 X-Sequence-Number: 33517 Craig Ringer writes: > Pavel Stehule wrote: >> these queries are executed in some special mode, but still it is more >> expensive than C a = a + 1 > ... and may have different rules, so you can't just write a simple "map > expressions to C equivalents" arithmetic evaluator. Yeah. As an example, overflow is supposed to be caught in "a + 1", unlike what would happen in C. In principle you could map some of the builtin operators into inline code, but it would be a great deal of work and the results would be un-portable. regards, tom lane