Re: PostgreSQL 8.4.8 bringing my website down every evening - Mailing list pgsql-general

From tv@fuzzy.cz
Subject Re: PostgreSQL 8.4.8 bringing my website down every evening
Date
Msg-id cd547502557b84d6622295fea38c8ef6.squirrel@sq.gransy.com
Whole thread Raw
In response to Re: PostgreSQL 8.4.8 bringing my website down every evening  (Alexander Farber <alexander.farber@gmail.com>)
List pgsql-general
> Sorry for the late reply - but I still haven't found a solution,
> for example I have a PHP script with 5 consecutive SELECT
> statements (source code + problem described again under:
>
> http://stackoverflow.com/questions/6458246/php-and-pgbouncer-in-transaction-mode-current-transaction-is-aborted
>
> ) and if I add $db->beginTransaction(); $db->commit();
> around each $db->prepare("select ..."); execute();
> then my script will fail very often with
>
> SQLSTATE[25P02]: In failed sql transaction: 7 ERROR:  current
> transaction is aborted, commands ignored until end of transaction
> block

In that case there's something wrong - probably an error or something,
that aborts a transaction. You have to investigate this first, see the
postgresql log and try to call errorInfo/errorCode of the PDO.

BTW why are you using prepared statements? That's great for running a
query multiple times with various parameter values, but according to the
PHP you're executing each statement exactly once. Even if the function is
called repeatedly, the statements will be prepared over and over because
you're calling a 'prepare' right before the execute.

So what you actually get is this

PREPARE
EXECUTE
PREPARE
EXECUTE

but you'd like to get this

PREPARE
EXECUTE
EXECUTE

If you can't do this, just use a plain PDO::query and those prepared
statement errors will be gone. Plus it might actually improve the
performance (with prepared statements the optimizer does not know the
actual values when planning the query, which sometimes prevents him from
choosing a good plan).

regards
Tomas


pgsql-general by date:

Previous
From: Vincent Veyron
Date:
Subject: Re: Oracle / PostgreSQL comparison...
Next
From: Craig Ringer
Date:
Subject: Re: Help making tablespaces work for my application