performance drop when function argument is evaluated in WHERE clause - Mailing list pgsql-performance

From Gerardo Herzig
Subject performance drop when function argument is evaluated in WHERE clause
Date
Msg-id 731037499.293695.1396958021532.JavaMail.root@fmed.uba.ar
Whole thread Raw
Responses Re: performance drop when function argument is evaluated in WHERE clause  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-performance
Hi all. I have a function that uses a "simple" select between 3 tables. There is a function argument to help choose how
aWHERE 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



pgsql-performance by date:

Previous
From: "Manoj Gadi"
Date:
Subject: Nested loop issue
Next
From: "Andrew W. Gibbs"
Date:
Subject: query against large table not using sensible index to find very small amount of data