in reply to How to optimise " csv into mysql " using Text:CSV_XS and DBD::Mysql
Why are you calling $sth->finish()?!
From DBI:
Indicate that no more data will be fetched from this statement handle before it is either executed again or destroyed. You almost certainly do not need to call this method.
Adding calls to finish after loop that fetches all rows is a common mistake, don't do it, it can mask genuine problems like uncaught fetch errors.
When all the data has been fetched from a SELECT statement, the driver will automatically call finish for you. So you should not call it explicitly except when you know that you've not fetched all the data from a statement handle and the handle won't be destroyed soon.
... etcetera ... go read the page at the link provided ...
I notice that the examples in DBD::MySQL, from which this code was probably more-or-less “lifted,” themselves include calls to finish(), which I think should be removed from that documentation.
Your design is appropriate in that it prepare()s the handle, then repeatedly uses it to execute() inserts that use placeholders. But I will wager that finish() is then doing all the wrong things to it, and I would gamble that this is where your speed is actually going-away.
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to optimise " csv into mysql " using Text:CSV_XS and DBD::Mysql
by taiko (Sexton) on Sep 04, 2015 at 22:11 UTC |