sql: create new accounts in one transaction

This prevents SQLite from synchronizing to disk after each statement,
saving time on high latency HDDs.
This commit is contained in:
Alexander Krotov
2020-09-18 19:41:41 +03:00
parent 5742360e3e
commit 0485c55718

View File

@@ -713,8 +713,9 @@ async fn open(
"First time init: creating tables in {:?}.",
dbfile.as_ref(),
);
sql.with_conn(move |conn| {
conn.execute_batch(
sql.with_conn(move |mut conn| {
let tx = conn.transaction()?;
tx.execute_batch(
r#"
CREATE TABLE config (id INTEGER PRIMARY KEY, keyname TEXT, value TEXT);
CREATE INDEX config_index1 ON config (keyname);
@@ -899,6 +900,7 @@ CREATE TABLE devmsglabels (
CREATE INDEX devmsglabels_index1 ON devmsglabels (label);
"#,
)?;
tx.commit()?;
Ok(())
})
.await?;