From: Robert Zenz <robert.zenz@sibvisions.com>
To: Postgres General <pgsql-general@postgresql.org>
Subject: Prepared statements (PREPARE and JDBC) are a lot slower than "normal" ones.
Date: Tue, 13 Feb 2018 09:25:22 +0000
Message-ID: <5A82AEFF.2020603@sibvisions.com> (raw)
We are seeing a quite heavy slow down when using prepared statements in 10.1.
I haven't done some thorough testing, to be honest, but what we are having is a
select from a view (complexity of it should not matter in my opinion), something
like this:
prepare TEST (text, int) select * from OUR_VIEW where COLUMNA = $1 and
COLUMNB = $2;
-- Actual test code follows.
-- Takes ~2 seconds.
select * from OUR_VIEW where COLUMNA = 'N' and COLUMNB = 35;
-- Takes ~10 seconds.
execute TEST ('N', 35);
Both return the same amount of rows, order of execution does not matter, these
times are reproducible. If the same select statement is executed through JDBC it
takes roughly 6 seconds (execution time only, no data fetched at that point).
I'm a little bit at a loss here. Is such a slow down "expected", did we simply
miss that prepared statements are slower? Or is there something else going on
that we are simply not aware of?
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: robert.zenz@sibvisions.com
Subject: Re: Prepared statements (PREPARE and JDBC) are a lot slower than "normal" ones.
In-Reply-To: <5A82AEFF.2020603@sibvisions.com>
References: <5A82AEFF.2020603@sibvisions.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox