Question re:DB package interaction with MySQL

From: Date: Fri, 24 Feb 2006 02:50:50 +0000
Subject: Question re:DB package interaction with MySQL
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-41468@lists.php.net to get a copy of this message
As I understand it, given the following code... $col_names = array ('col1','col2'); $rand = array( array('12341234', '345782'), array('23423', '0983450934') ); $dsn = 'mysql://root:secret@localhost/database1'; $db =& DB::connect($dsn); $sth = $db->autoPrepare('randtest',$col_names,DB_AUTOQUERY_INSERT); if (DB::isError($sth)) die ($sth->getMessage()); $sth = $db->executeMultiple($sth, $rand); ...DB will create and send two separate INSERT queries. My question is, why does DB create two separate queries, when MySQL's capable of combining multiple INSERTS into a single statement? (i.e. INSERT INTO randtest VALUES ('12341234', '345782'), ('23423', '0983450934');) I ran a slightly more complex test, with a pre-generated set of 100,000 rows, and DB took 40-60 seconds to insert, whereas everything rolled into a single query took a single second to insert. It seems the alternate syntax would result in a huge performance gain here...

« previous php.pear.dev (#41468) next »