plpgsql slower than sql

Started by Eric Jainover 23 years ago1 messagesgeneral
Jump to latest
#1Eric Jain
jain@gmx.net

I have a simple procedure involving the following two steps:

1) Check if a certain record exist (SELECT)

2) Create, update or leave the record as is depending on a simple
condition (INSERT, UPDATE, -)

I am aware of two approaches for efficiently implementing this
procedure in a Java application:

A) Use 3 PreparedStatements, handle logic in application.

B) Use 1 PreparedStatement or CallableStatement, put logic in plpgsql
function.

Naturally, I expected the latter to be faster. To my surprise it is
considerable slower. I therefore assume that this is either a known
issue or perhaps I am doing something wrong?