From 16e7c9c9079cfc9d8292de66f81cda0996012ec3 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 26 May 2016 21:02:58 +0100 Subject: Use SQL copy to upload file list faster --- gentoobrowse-api/service/maintenanceimpl.cpp | 14 +++++++++----- 1 file 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 -- cgit v1.2.3