From: Mario Splivalo <mario.splivalo@megafon.hr>
To: pgsql-performance@postgresql.org
Cc: pgsql-jdbc@postgresql.org
Subject: Re: [PERFORM] Query much slower when run from postgres function
Date: Mon, 09 Mar 2009 20:26:05 +0100
Message-ID: <49B56D4D.9090605@megafon.hr> (raw)
In-Reply-To: <87fxhmmygj.fsf@meuh.mnc.lan>
References: <49B51B60.6030600@megafon.hr>
<27649.1236616294@sss.pgh.pa.us>
<87fxhmmygj.fsf@meuh.mnc.lan>
Guillaume Cottenceau wrote:
>>> Now I'm confused, why is 'sql' function much slower than 'direct' SELECT?
>> Usually the reason for this is that the planner chooses a different plan
>> when it has knowledge of the particular value you are searching for than
>> when it does not.
>
> Yes, and since Mario is coming from JDBC, I'll share my part on
> this: I also noticed some very wrong plans in JDBC because of the
> "optimization" in prepared statements consisting of planning once
> for all runs, e.g. without any parameter values to help planning.
>
For what is worth:
When I call postgres function via JDBC, I have almost the same execution
time as when calling function from psql.
When I call SELECT COUNT(*)... WHERE... query from JDBC, I again have
almost the same execution time as when executing query from psql.
Postgres function takes around 200ms, and SELECT query takes around 2-4ms.
Mike
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 using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: mario.splivalo@megafon.hr, pgsql-jdbc@postgresql.org
Subject: Re: [PERFORM] Query much slower when run from postgres function
In-Reply-To: <49B56D4D.9090605@megafon.hr>
* 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