Set SQLite page size to 4K: Closes #7423
This speeds up startup time immensely, probably due it matching the the filesystem's or Linux memory mgmt's page size. It's also expected that this will improve database performance in other ways, as the default was 1K, meaning potentially more I/O than necessary for standard operations.
This commit is contained in:
parent
20ac1078f6
commit
4b03618f08
2 changed files with 33 additions and 0 deletions
4
sql/version-014.sql
Normal file
4
sql/version-014.sql
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
--
|
||||||
|
-- Dummy file to upgrade to version 14. See imap-db-database.vala for the
|
||||||
|
-- actual code that gets executed here.
|
||||||
|
--
|
||||||
|
|
@ -83,6 +83,10 @@ private class Geary.ImapDB.Database : Geary.Db.VersionedDatabase {
|
||||||
case 13:
|
case 13:
|
||||||
post_upgrade_populate_additional_attachments();
|
post_upgrade_populate_additional_attachments();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 14:
|
||||||
|
post_upgrade_expand_page_size();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -272,6 +276,31 @@ private class Geary.ImapDB.Database : Geary.Db.VersionedDatabase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Version 14.
|
||||||
|
private void post_upgrade_expand_page_size() {
|
||||||
|
try {
|
||||||
|
// When the MessageSearchTable is first touched, SQLite seems to
|
||||||
|
// read the whole table into memory (or an awful lot of data,
|
||||||
|
// either way). This was causing slowness when Geary first started
|
||||||
|
// and checked for any messages not yet in the search table. With
|
||||||
|
// the database's page_size set to 4096, the reads seem to happen
|
||||||
|
// about 2 orders of magnitude quicker, probably because 4096
|
||||||
|
// matches the default filesystem block size and/or Linux's default
|
||||||
|
// memory page size. With this set, the full read into memory is
|
||||||
|
// barely noticeable even on slow machines.
|
||||||
|
|
||||||
|
// NOTE: these can't be in the .sql file itself because they must
|
||||||
|
// be back to back, outside of a transaction.
|
||||||
|
exec("""
|
||||||
|
PRAGMA page_size = 4096;
|
||||||
|
VACUUM;
|
||||||
|
""");
|
||||||
|
} catch (Error e) {
|
||||||
|
debug("Error bumping page_size or vacuuming database; performance may be degraded: %s",
|
||||||
|
e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void on_prepare_database_connection(Db.Connection cx) throws Error {
|
private void on_prepare_database_connection(Db.Connection cx) throws Error {
|
||||||
cx.set_busy_timeout_msec(Db.Connection.RECOMMENDED_BUSY_TIMEOUT_MSEC);
|
cx.set_busy_timeout_msec(Db.Connection.RECOMMENDED_BUSY_TIMEOUT_MSEC);
|
||||||
cx.set_foreign_keys(true);
|
cx.set_foreign_keys(true);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue