[geary/geary-0.11] Don't try to FTS index messages that don't meet the field requirements.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/geary-0.11] Don't try to FTS index messages that don't meet the field requirements.
- Date: Sat, 28 Jan 2017 04:15:15 +0000 (UTC)
commit 404b12833980c2942b3466160a6cadfbc32f6ffb
Author: Michael James Gratton <mike vee net>
Date: Fri Jan 13 16:02:09 2017 +1100
Don't try to FTS index messages that don't meet the field requirements.
Bug 776654.
* src/engine/imap-db/imap-db-folder.vala (Folder): Add
REQUIRED_FTS_FIELDS constant that specifys what are the required fields
for FTS.
* src/engine/imap-db/imap-db-account.vala
(Account::populate_search_table_batch_async): Ensure rows returned meet
REQUIRED_FTS_FIELDS requirements.
src/engine/imap-db/imap-db-account.vala | 19 +++++++++----------
src/engine/imap-db/imap-db-folder.vala | 13 +++++++++++--
2 files changed, 20 insertions(+), 12 deletions(-)
---
diff --git a/src/engine/imap-db/imap-db-account.vala b/src/engine/imap-db/imap-db-account.vala
index 253f561..38741c1 100644
--- a/src/engine/imap-db/imap-db-account.vala
+++ b/src/engine/imap-db/imap-db-account.vala
@@ -1589,21 +1589,20 @@ private class Geary.ImapDB.Account : BaseObject {
int count = 0, total_unindexed = 0;
yield db.exec_transaction_async(Db.TransactionType.RW, (cx, cancellable) => {
- // Embedding a SELECT within a SELECT is painfully slow with SQLite, so manually
- // perform the operation
- //
- // Get all rowids for the MessageSearchTable and turn it into a HashSet
+ // Embedding a SELECT within a SELECT is painfully slow
+ // with SQLite, and a LEFT OUTER JOIN will still take in
+ // the order of seconds, so manually perform the operation
+
Db.Statement stmt = cx.prepare("""
- SELECT docid
- FROM MessageSearchTable
+ SELECT docid FROM MessageSearchTable
""");
Gee.HashSet<int64?> search_ids = do_build_rowid_set(stmt.exec(cancellable), cancellable);
-
- // Do the same for the MessageTable
+
stmt = cx.prepare("""
- SELECT id
- FROM MessageTable
+ SELECT id FROM MessageTable WHERE (fields & ?) = ?
""");
+ stmt.bind_uint(0, Geary.ImapDB.Folder.REQUIRED_FTS_FIELDS);
+ stmt.bind_uint(1, Geary.ImapDB.Folder.REQUIRED_FTS_FIELDS);
Gee.HashSet<int64?> message_ids = do_build_rowid_set(stmt.exec(cancellable), cancellable);
// guesstimate at the number that need to be indexed ... technically if this is zero then
diff --git a/src/engine/imap-db/imap-db-folder.vala b/src/engine/imap-db/imap-db-folder.vala
index 76ab87b..b826bf2 100644
--- a/src/engine/imap-db/imap-db-folder.vala
+++ b/src/engine/imap-db/imap-db-folder.vala
@@ -16,8 +16,17 @@
*/
private class Geary.ImapDB.Folder : BaseObject, Geary.ReferenceSemantics {
- public const Geary.Email.Field REQUIRED_FIELDS = Geary.Email.Field.PROPERTIES;
-
+
+ /**
+ * Fields required for a message to be stored in the database.
+ */
+ public const Geary.Email.Field REQUIRED_FIELDS = Geary.Email.Field.PROPERTIES|Email.Field.REFERENCES;
+
+ /**
+ * Fields required for a message to be considered for full-text indexing.
+ */
+ public const Geary.Email.Field REQUIRED_FTS_FIELDS = Geary.Email.REQUIRED_FOR_MESSAGE;
+
private const int LIST_EMAIL_WITH_MESSAGE_CHUNK_COUNT = 10;
private const int LIST_EMAIL_METADATA_COUNT = 100;
private const int LIST_EMAIL_FIELDS_CHUNK_COUNT = 500;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]