"Adnan DURSUN" <a_dursun@xxxxxxxxxxx> writes: >>>> EXPLAIN ANALYZE EXECUTE stmt (...); > Here is the EXPLAIN ANALYZE output for prepared statement : This is exactly the same as the other plan --- you did not parameterize the query. To see what's going on, you need to insert PREPARE parameters in the places where the function uses plpgsql variables. regards, tom lane