Batching saves?

37 views
Skip to first unread message

randian

unread,
Jun 7, 2012, 8:25:57 PM6/7/12
to rose-db...@googlegroups.com
Is there any way to do batch save in Rose? If you have, say, 10,000 rows, doing them all as a single INSERT with 10,000 VALUES instead of 10,000 INSERTs is the difference between minutes and seconds of runtime.

John Siracusa

unread,
Jun 7, 2012, 8:48:54 PM6/7/12
to rose-db...@googlegroups.com
No. Bulk loading is a very database-specific feature. For fast bulk
loads, write the SQL or other commands required by your database and
run them manually (within Perl or otherwise).

-John

Perrin Harkins

unread,
Jun 10, 2012, 4:15:36 PM6/10/12
to rose-db...@googlegroups.com
Just to add a little anecdotal support for this, I've found that, with
MySQL, writing out a file with Text::CSV_XS and loading it with LOAD
DATA LOCAL INFILE is many times faster than a multi-row insert through
DBI as soon as you get to a significant number of rows.

- Perrin

Darren Duncan

unread,
Jun 25, 2012, 1:39:13 AM6/25/12
to rose-db...@googlegroups.com
If you're talking about the ability to insert multiple rows in one statement,
like this:

insert into foo (bar, baz) values
(1, 2),
(3, 4),
(5, 6);

Then this is in fact defined by the SQL standard, and is supported in many
DBMSs. I would not call that a "very database-specific feature" at all. Maybe
instead say "only some databases support that standard feature".

-- Darren Duncan

randian

unread,
Jun 25, 2012, 4:24:05 AM6/25/12
to rose-db...@googlegroups.com
That's exactly what I was talking about.
Reply all
Reply to author
Forward
0 new messages