I've just made some test populating a database with millions of rows and
the difference between ->save() and ->saveMany() wasn't very important
(~100 query/seconds vs ~125 q/sec) (on a old local server).
But then I've made it work throught
$this->MyModel->getDataSource()->insertMulti('MyModel', $fields, $values)
and the difference is so HUGE ! I've been able to pass ~2000 q/sec
continuously and my code wasn't optimized.
The fact is, parsing the data to go from a standard $dataToSave: array(
'MyModel' => array('data1' ...) ) to a $query compatible with insertMulti
is just a breeze. Why not use this method with the ->saveMany() ? It's just
way more efficient data processing.
Thanks anyhow for the info, saved me probably a month of passive computing
^^
Le mardi 30 septembre 2008 13:12:22 UTC+2, JadB a écrit :
>
>
> DboMysql::insertMulti will return an SQL query similar to the one you
> are looking to get: INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),
> (7,8,9);
>
> You could add this new method to app_controller.php if you want:
>
> function multiSave(&$model, $values, $fields = null)
> {
> $this->db =& $model->getDataSource();
> $this->db->insertMulti($model->table, $fields, $values);
> }
>
> Pass to it something like:
>
> $values = array('(1, 2, 3)', '(4, 5, 6)', '(7, 8, 9)');
> $fields = array('a','b','c');
>
> I might be wrong, but this works for me so far and isn't really any
> kind of 'hack', it's just using what's there in the framework. Hope it
> helps!
>
> JadB
> http://loudbaking.myeasyscripts.com
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.