Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 101F2632FF8 for ; Tue, 22 Dec 2009 08:35:45 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 01393-06 for ; Tue, 22 Dec 2009 12:35:27 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp-OUT05A.alice.it (smtp-OUT05A.alice.it [85.33.3.5]) by mail.postgresql.org (Postfix) with ESMTP id E1F36632BEA for ; Tue, 22 Dec 2009 08:35:33 -0400 (AST) Received: from FBCMMO02.fbc.local ([192.168.68.196]) by smtp-OUT05A.alice.it with Microsoft SMTPSVC(6.0.3790.3959); Tue, 22 Dec 2009 13:35:29 +0100 Received: from FBCMCL01B01.fbc.local ([192.168.69.82]) by FBCMMO02.fbc.local with Microsoft SMTPSVC(6.0.3790.3959); Tue, 22 Dec 2009 13:35:29 +0100 Received: from lan.webthatworks.it ([79.0.145.79]) by FBCMCL01B01.fbc.local with Microsoft SMTPSVC(6.0.3790.3959); Tue, 22 Dec 2009 13:35:29 +0100 Received: from dawn.webthatworks.it (dawn.webthatworks.it [192.168.1.12]) by lan.webthatworks.it (Postfix) with ESMTP id 6B08D3005EF for ; Tue, 22 Dec 2009 13:35:28 +0100 (CET) Received: from dawn.webthatworks.it (localhost [127.0.0.1]) by dawn.webthatworks.it (Postfix) with ESMTP id 307573DA9B for ; Tue, 22 Dec 2009 13:35:28 +0100 (CET) Date: Tue, 22 Dec 2009 13:35:27 +0100 From: Ivan Sergio Borgonovo To: pgsql-sql@postgresql.org Subject: short-cutting if sum()>constant Message-ID: <20091222133527.3007bd96@dawn.webthatworks.it> Organization: http://www.webthatworks.it X-Mailer: Claws Mail 3.7.3 (GTK+ 2.18.5; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 22 Dec 2009 12:35:29.0512 (UTC) FILETIME=[3ECB1E80:01CA8303] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.669 tagged_above=-10 required=5 tests=AWL=-0.929, BAYES_20=-0.74 X-Spam-Level: X-Archive-Number: 200912/56 X-Sequence-Number: 33494 Hi, I'd like to know if select sum(qty) from t where status=37; is > constant. qty is always >0. Is there a way to skip examining further rows and return a result ASAP? -- Ivan Sergio Borgonovo http://www.webthatworks.it