diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-05-26 21:02:58 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-05-26 21:02:58 +0100 |
commit | 642c28b7f578e0a5c07722a5cb4a1a640d27f5ed (patch) | |
tree | d070ffbe2a12e0ed3d55120568ebea61b8740c41 | |
parent | Improve file list merging with second temp table (diff) | |
download | gentoobrowse-api-642c28b7f578e0a5c07722a5cb4a1a640d27f5ed.tar.bz2 gentoobrowse-api-642c28b7f578e0a5c07722a5cb4a1a640d27f5ed.tar.xz gentoobrowse-api-642c28b7f578e0a5c07722a5cb4a1a640d27f5ed.zip |
Use SQL copy to upload file list faster
-rw-r--r-- | gentoobrowse-api/service/maintenanceimpl.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/gentoobrowse-api/service/maintenanceimpl.cpp b/gentoobrowse-api/service/maintenanceimpl.cpp index 495e908..2bb43af 100644 --- a/gentoobrowse-api/service/maintenanceimpl.cpp +++ b/gentoobrowse-api/service/maintenanceimpl.cpp @@ -137,16 +137,20 @@ namespace Gentoo { boost::filesystem::create_symlink(p, tmp / n); }); dbc->execute(sql::maintenance::fileListCreateRaw.getSql()); - auto i = dbc->modify("INSERT INTO filelistraw(filename, filesize, filemtime) VALUES(?, ?, ?)"); + dbc->beginBulkUpload("filelistraw", ""); + char buf[BUFSIZ]; for (boost::filesystem::recursive_directory_iterator d(tmp, boost::filesystem::symlink_option::recurse); d != boost::filesystem::recursive_directory_iterator(); d++) { if (boost::filesystem::is_regular_file(d->status())) { - i->bindParamS(0, d->path().lexically_relative(tmp).string()); - i->bindParamI(1, boost::filesystem::file_size(*d)); - i->bindParamT(2, boost::posix_time::from_time_t(boost::filesystem::last_write_time(*d))); - i->execute(); + auto len = snprintf(buf, BUFSIZ, "%s\t%ld\t%s\n", + d->path().lexically_relative(tmp).c_str(), + boost::filesystem::file_size(*d), + boost::posix_time::to_iso_extended_string( + boost::posix_time::from_time_t(boost::filesystem::last_write_time(*d))).c_str()); + dbc->bulkUploadData(buf, len); } } + dbc->endBulkUpload(nullptr); } void |