Yes, I noticed that my request is already listed in the issue tracker -
unfortunately after I wrote my post :)

Btw, I recommend to disable the preparing of sql statements for the MySQL
Adapters by default.



Darby Felton wrote:
> 
> Christian Ehmig wrote:
>> Hi!
>> 
>> Some time ago I noticed that Zend_DB and especially
>> Zend_Db_Adapter_Abstract
>> prepare ANY statement except when you use the following code fragment:
>> 
>> $result = $db->getConnection()->exec('DROP TABLE bugs');
>> 
>> The methodology of preparing each statement is necessary for Oracle as
>> far
>> as I remember. Regarding MySQL it has a huge impact on performance
>> instead!
>> The one and only time you need to prepare a statement in MySQL is if you
>> use
>> the prepared query several times with different values bound to the ?
>> parameters. 
>> 
>> I compared the Zend:DB MySQL adapters to ADO, Pear and Native PHP code
>> inserting 100.000 rows.
>> 
>> Code looked something like this:
>> 
>> for ($i = 0; $i < 100.000; $i++) {
>> 
>> $data = array(
>>     'text' => 'somedummytext'
>> );
>> 
>> $db->insert('testtable', $data);
>> }
>> 
>> Now, the Zend MySQL adapters send 200.000 queries to the mysql server in
>> this case, a "prepare & execute" for each call to $db->insert().
>> 
>> This resulted in double execution time compared to native php access in
>> other words a performance drop of 100%! Of course, SELECT statements
>> (fetchRow, fetchAll, etc.) are prepared, too. Just imagine you use around
>> 100 select queries to render a site - each select will be individually
>> prepared, although this is completely nonsense in my opinion.
>> 
>> Are there any plans for disabling the "automatic prepare feature" or any
>> other hints on this issue?
> 
> Yes, actually, this is a known issue and planned to be completed soon:
> 
> http://framework.zend.com/issues/browse/ZF-1398
> 
> Please feel free to jump in and contribute!
> 
> http://framework.zend.com/community/contribute
> 
> Best regards,
> Darby
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Zend_DB-performance-issue-tp14233508s16154p14255161.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to