Note that there are some explanatory texts on larger screens.

plurals
  1. POYii Framework - InnoDB vs MyISAM
    primarykey
    data
    text
    <p>i have a question: i have built a big application with Yii and InnoDB and came to the problem, that the insert/update durate really really long time, here is my php report:</p> <p>INNODB: admin User update 55.247464895248 seconds ekuskov User update 13.282548904419 seconds doriwall User update 0.002094030380249 seconds</p> <p>MYISAM: admin User update 7.8317859172821 seconds ekuskov User update 1.6304929256439 seconds doriwall User update 0.0020859241485596 seconds</p> <p>Can anyone suggest some solution to speed up the insert/update?</p> <p>EDIT ----------------------------------------------</p> <p>Now i used some very simple insert loop:</p> <pre><code>public function run($args) { $time = -microtime(true); $begin = DateTime::createFromFormat('Y-m-d H:i:s', '2010-01-01 00:00:00'); $end = DateTime::createFromFormat('Y-m-d H:i:s', '2013-01-01 00:00:00'); $end-&gt;add(new DateInterval('P1D')); $interval = DateInterval::createFromDateString('1 day'); $days = new DatePeriod($begin, $interval, $end); foreach ( $days as $day ) { echo "i"; $track = new TimeTracking(); $track-&gt;user_id = 25; $track-&gt;date = $day-&gt;format('Y-m-d H:i:s'); $track-&gt;active = 4; $track-&gt;save(false); } $time += microtime(true); echo count($days)." items insert - $time seconds\n"; } </code></pre> <p>and now the INSERT times are following:</p> <p>InnoDB: items insert - 72.269570827484 seconds</p> <p>MyISAM: items insert - 0.87537479400635 seconds</p> <p><em><strong>[EDIT]</em></strong> And now i was counting time for whole SAVE method and Yii Models "save()" function:</p> <p>UPDATE: model->save(false) - 0.1096498966217 seconds</p> <p>UPDATE: controller save function () - 0.1302649974823 seconds</p> <p>CREATE: model->save(false) - 0.052282094955444 seconds</p> <p>CREATE: controller save function () - 0.057214975357056 seconds</p> <p>Why just save() method takes so long?</p> <p><em><strong>[EDIT]</em></strong> I have tested save() vs command() and they durate same:</p> <pre><code>$track-&gt;save(false); </code></pre> <p>or</p> <pre><code>$command = Yii::app()-&gt;db-&gt;createCommand(); $command-&gt;insert('timeTracking', array( 'id'=&gt;NULL, 'date'=&gt;$track-&gt;date, 'active'=&gt;$track-&gt;active, 'user_id'=&gt;$track-&gt;user_id, )); </code></pre> <p><strong>EDIT</strong> -----------------------------</p> <p>And here is a statistic for inserting 1,097 Objects: </p> <pre><code>save(): 0.86-0.94, $command-&gt;insert(): 0.67-0.72, $command-&gt;execute(): 0.46-0.48, mysql_query(): 0.33-0.36 </code></pre> <p><strong>FINALLY ANSWER:</strong> If you want to use some massive INSERT or UPDATE methods you should consider to create the functions with direct MYSQL Calls, there you will save almost 70% of execution time.</p> <p>Regards,</p> <p>Edgar</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload