[geary] Don't bother adding an email to the FTS table if all cols will be empty.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary] Don't bother adding an email to the FTS table if all cols will be empty.
- Date: Sat, 15 Oct 2016 01:07:57 +0000 (UTC)
commit 06a57fbe4934ea653a8a5bf2c8385c30f276452a
Author: Michael James Gratton <mike vee net>
Date: Fri Oct 14 12:08:35 2016 +1100
Don't bother adding an email to the FTS table if all cols will be empty.
Investigation into Bug 772522 showed that often when a message is first
added to MessageSearchTable, all columns had null or empty strings as
values, which constitutes an undesirable write IO overhead.
* src/engine/imap-db/imap-db-folder.vala
(Folder::do_add_email_to_search_table): Ensure that there is at least
one non-empty value before doing the INSERT.
src/engine/imap-db/imap-db-folder.vala | 53 +++++++++++++++++++++----------
1 files changed, 36 insertions(+), 17 deletions(-)
---
diff --git a/src/engine/imap-db/imap-db-folder.vala b/src/engine/imap-db/imap-db-folder.vala
index b3e02e8..9d0b90b 100644
--- a/src/engine/imap-db/imap-db-folder.vala
+++ b/src/engine/imap-db/imap-db-folder.vala
@@ -1405,24 +1405,43 @@ private class Geary.ImapDB.Folder : BaseObject, Geary.ReferenceSemantics {
} catch (Error e) {
// Ignore.
}
-
- Db.Statement stmt = cx.prepare("""
- INSERT INTO MessageSearchTable
- (docid, body, attachment, subject, from_field, receivers, cc, bcc)
- VALUES (?, ?, ?, ?, ?, ?, ?, ?)
- """);
- stmt.bind_rowid(0, message_id);
- stmt.bind_string(1, body);
- stmt.bind_string(2, email.get_searchable_attachment_list());
- stmt.bind_string(3, (email.subject != null ? email.subject.to_searchable_string() : null));
- stmt.bind_string(4, (email.from != null ? email.from.to_searchable_string() : null));
- stmt.bind_string(5, recipients);
- stmt.bind_string(6, (email.cc != null ? email.cc.to_searchable_string() : null));
- stmt.bind_string(7, (email.bcc != null ? email.bcc.to_searchable_string() : null));
-
- stmt.exec_insert(cancellable);
+
+ // Often when Geary first adds a message to the FTS table
+ // these fields will all be null or empty strings. Check that
+ // this isn't the case beforehand to avoid the IO overhead.
+
+ string? attachments = email.get_searchable_attachment_list();
+ string? subject = email.subject != null ? email.subject.to_searchable_string() : null;
+ string? from = email.from != null ? email.from.to_searchable_string() : null;
+ string? cc = email.cc != null ? email.cc.to_searchable_string() : null;
+ string? bcc = email.bcc != null ? email.bcc.to_searchable_string() : null;
+
+ if (!Geary.String.is_empty(body) ||
+ !Geary.String.is_empty(attachments) ||
+ !Geary.String.is_empty(subject) ||
+ !Geary.String.is_empty(from) ||
+ !Geary.String.is_empty(recipients) ||
+ !Geary.String.is_empty(cc) ||
+ !Geary.String.is_empty(bcc)) {
+
+ Db.Statement stmt = cx.prepare("""
+ INSERT INTO MessageSearchTable
+ (docid, body, attachment, subject, from_field, receivers, cc, bcc)
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)
+ """);
+ stmt.bind_rowid(0, message_id);
+ stmt.bind_string(1, body);
+ stmt.bind_string(2, attachments);
+ stmt.bind_string(3, subject);
+ stmt.bind_string(4, from);
+ stmt.bind_string(5, recipients);
+ stmt.bind_string(6, cc);
+ stmt.bind_string(7, bcc);
+
+ stmt.exec_insert(cancellable);
+ }
}
-
+
private static bool do_check_for_message_search_row(Db.Connection cx, int64 message_id,
Cancellable? cancellable) throws Error {
Db.Statement stmt = cx.prepare("SELECT 'TRUE' FROM MessageSearchTable WHERE docid=?");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]