Re: Reusing cached prepared statement slow after 5 executions - Mailing list pgsql-general

From Albe Laurenz
Subject Re: Reusing cached prepared statement slow after 5 executions
Date
Msg-id D960CB61B694CF459DCFB4B0128514C20694A8A8@exadv11.host.magwien.gv.at
Whole thread Raw
In response to Re: Reusing cached prepared statement slow after 5 executions  (Dean Rasheed <dean.a.rasheed@gmail.com>)
List pgsql-general
Dean Rasheed wrote:
>> I can confirm, when I call ps.setPrepareThreshold(1) the query is
slow
>> immediately, so the plan must be different with the server prepared
>> statements.
>
> You can confirm that from psql by doing
>
> EXPLAIN ANALYSE SELECT ... ;
>
> and then
>
> PREPARE ps( ... ) AS SELECT ... ;
> EXPLAIN ANALYSE EXECUTE ps ( ... ) ;
>
> using your query and the parameters in question.
>
> It is entirely possible that the plan chosen for the prepared
> statement will be worse than the one used when the parameters are
> known at planning time. The prepared statement doesn't know what
> parameters are going to be used, so it can't always come up with the
> best plan. See the notes in the PREPARE manual page:
> http://www.postgresql.org/docs/9.0/static/sql-prepare.html

Could the parameter cursor_tuple_fraction play a role here too?

Yours,
Laurenz Albe

pgsql-general by date:

Previous
From: Leif Biberg Kristensen
Date:
Subject: Re: An amusing MySQL weakness--not!
Next
From: Sim Zacks
Date:
Subject: discard on constraint violation