Re: [Q] PDO use to bind arrays for insert

From: Andrew McMillan <andrew(at)morphoss(dot)com>
To: V S P <toreason(at)fastmail(dot)fm>
Cc: pgsql-php(at)postgresql(dot)org
Subject: Re: [Q] PDO use to bind arrays for insert
Date: 2008-11-17 08:26:42
Message-ID: 1226910402.5577.280.camel@happy.mcmillan.net.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

On Sun, 2008-11-16 at 23:26 -0500, V S P wrote:
> Hi,
> thank you Andrew.
>
> do you know if query planning happens only once
> for the prepared Insert statements
> where data is fed from within a client loop
>
> foreach ...
> execute prepared insert
> end
>
> and if it happens once -- is it on the first insert?

Yes, it happens once on the first one.

>
> And the last question -- with pgpool
> do prepared statements last between
> different client connections?
>
> that is If I have say apache setup with 5 processes
> (and therefore PHP can be invoked within 5 worker processes
> simultaneously)
>
> would the Prepared statements last across invocations

Prepared statements are per connection, and the actions taken at the
close of a connection to pgpool to ready the pool for connection from a
different client will very likely deallocate any prepared statements.
The developers are usually actively trying to minimise pollution of
state from one connection to the next, but persistence of prepared
statements might be a different kettle of fish...

Read here for more information. In paricular note that PREPARE has it's
greatest impact when used on complex SQL - i.e. probably not INSERT
statements:

http://www.postgresql.org/docs/8.3/interactive/sql-prepare.html

If you really need performance on a stream of inserts it probably is
better to feed them to a separate daemon to specifically handle them
serially, otherwise any peak load on your website is going to also peak
load your DB server. If you can stream the inserts separately you can
potentially shift that load. Obviously no good if your inserts aren't
blind, but when there are large streams of them they often are only
looked at statistically at a later time.

Your questions here are really getting beyond the scope of the pgsql-PHP
list though, and you might want to try asking them on pgsql-general or
something where you will have a wider resource of PostgreSQL experts...

Cheers,
Andrew McMillan.

------------------------------------------------------------------------
andrew (AT) morphoss (DOT) com +64(272)DEBIAN
"... all the modern inconveniences ..."
-- Mark Twain
------------------------------------------------------------------------

In response to

Responses

Browse pgsql-php by date

  From Date Subject
Next Message V S P 2008-11-17 08:55:55 Re: [Q] PDO use to bind arrays for insert
Previous Message V S P 2008-11-17 04:26:58 Re: [Q] PDO use to bind arrays for insert