Search Postgresql Archives

Re: PostgreSQL 8.4.8 bringing my website down every evening

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 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


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux