Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 8A4BF64FE7F for ; Sun, 16 Nov 2008 23:01:39 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 16519-05 for ; Sun, 16 Nov 2008 23:01:20 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from out1.smtp.messagingengine.com (out1.smtp.messagingengine.com [66.111.4.25]) by mail.postgresql.org (Postfix) with ESMTP id DF3BD64FC4F for ; Sun, 16 Nov 2008 23:01:20 -0400 (AST) Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id CA2F81B7299; Sun, 16 Nov 2008 22:01:14 -0500 (EST) Received: from web5.messagingengine.com ([10.202.2.214]) by compute1.internal (MEProxy); Sun, 16 Nov 2008 22:01:14 -0500 Received: by web5.messagingengine.com (Postfix, from userid 99) id E6FB7254B1; Sun, 16 Nov 2008 22:01:13 -0500 (EST) Message-Id: <1226890873.32288.1285117971@webmail.messagingengine.com> X-Sasl-Enc: wUNV3A4AMTwYXVbHLe8sb3OVMN5E9CPkTX2x6sVlxn2w 1226890873 From: "V S P" To: knl@bitflop.com Cc: pgsql-php@postgresql.org Content-Disposition: inline Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="KOI8-R" MIME-Version: 1.0 X-Mailer: MessagingEngine.com Webmail Interface References: <1226803530.24888.1284994985@webmail.messagingengine.com> <492093A5.7040606@gmail.com> <20081117002630.d86160fd.knl@bitflop.com> Subject: Re: [Q] PDO use to bind arrays for insert In-Reply-To: <20081117002630.d86160fd.knl@bitflop.com> Date: Sun, 16 Nov 2008 22:01:13 -0500 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200811/13 X-Sequence-Number: 3924 Hi Kim, thank you for the reply Yes, I thought I can use prepared statements to optimize the insert speed. I was just looking for a further optimization (because prepared inserts still cause a network trip for every insert (but SQL is not parsed everytime because it is prepared)) In otherwords what I wanted (conseptually is) insert into work_items (work_id, work_desc) values (:bound_ar_of_work_ids, :bound_ar_of_work_desc) bindParameter(":bound_ar_of_work_ids", ar_of_work_ids, PDO::ARRAY_INT); bindParameter(":bound_ar_of_work_desc",ar_of_work_desc,PDO::ARRAY_STRING); I understand that I could simply generate the string such as insert into work_items (work_id, work_desc) values ( ("id_val1", "desc_val1"), ("id_val2", "desc_val2"), ("id_val3","desc_val3") ... ); But the problem with the above that it will not be prepared -- so the SQL engine will be parsing it (also some SQL engines besides parsing, may assign a Optimizer plan to prepared queries, not sure if PG does that) I think Chris @ dmagick pointed to a raw string functionality that -- so I will need to figure out if a) it actually saves on parsing b) if it will work with PG connection pooling (which I am not using yet, but will in the future). > $stmt->bindParam (':work_desc', $work_desc, PDO::PARAM_STR); > > for ($i = 0; $i < count($my_array); $i++) { > > $work_desc = $my_array[$i]; > > $stmt->execute(); > > } > > Kim Lesmer -- V S P toreason@fastmail.fm -- http://www.fastmail.fm - The professional email service