Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WXUbP-0004HM-Gn for pgsql-performance@arkaria.postgresql.org; Tue, 08 Apr 2014 11:54:07 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WXUbO-0006qu-Rx for pgsql-performance@arkaria.postgresql.org; Tue, 08 Apr 2014 11:54:06 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WXUbN-0006qj-P5; Tue, 08 Apr 2014 11:54:05 +0000 Received: from mail.fmed.uba.ar ([157.92.152.1] helo=azteca.fmed.uba.ar) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WXUbC-0006H5-OH; Tue, 08 Apr 2014 11:54:05 +0000 Received: from localhost (localhost [127.0.0.1]) by azteca.fmed.uba.ar (Postfix) with ESMTP id D5E245CA05D; Tue, 8 Apr 2014 08:53:49 -0300 (ART) X-Virus-Scanned: amavisd-new at fmed.uba.ar Received: from azteca.fmed.uba.ar ([127.0.0.1]) by localhost (azteca.fmed.uba.ar [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wYtyKycRBHNH; Tue, 8 Apr 2014 08:53:43 -0300 (ART) Received: from azteca.fmed.uba.ar (azteca.fmed.uba.ar [157.92.152.1]) by azteca.fmed.uba.ar (Postfix) with ESMTP id A709E5CA06A; Tue, 8 Apr 2014 08:53:41 -0300 (ART) Date: Tue, 8 Apr 2014 08:53:41 -0300 (ART) From: Gerardo Herzig To: pgsql-performance@postgresql.org, "pgsql-sql " Message-ID: <731037499.293695.1396958021532.JavaMail.root@fmed.uba.ar> In-Reply-To: <1321795206.293156.1396957278252.JavaMail.root@fmed.uba.ar> Subject: performance drop when function argument is evaluated in WHERE clause MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [201.235.34.67] X-Mailer: Zimbra 7.2.0_GA_2669 (ZimbraWebClient - GC30 (Linux)/7.2.0_GA_2669) X-Pg-Spam-Score: -2.9 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Hi all. I have a function that uses a "simple" select between 3 tables. There is a function argument to help choose how a WHERE clause applies. This is the code section: select * from.... [...] where case $3 when 'I' then [filter 1] when 'E' then [filter 2] when 'P' then [filter 3] else true end When the function is called with, say, parameter $3 = 'I', the funcion run in 250ms, but when there is no case involved, and i call directly "with [filter 1]" the function runs in 70ms. Looks like the CASE is doing something nasty. Any hints about this? Thanks! Gerardo -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance