From 18cd8ba0b6dc3bcfa68f77614fc2b59396968f6d Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 8 Jun 2017 13:58:36 +0200 Subject: [PATCH] Add indices for HistoryAtimeIndex and CompletionHistoryAtimeIndex before ------ sqlite> SELECT * FROM History where not redirect and not url like "qute://%" and atime > ? and atime <= ? ORDER BY atime desc; Run Time: real 0.072 user 0.063334 sys 0.010000 sqlite> explain query plan SELECT * FROM History where not redirect and not url like "qute://%" and atime > ? and atime <= ? ORDER BY atime desc; 0|0|0|SCAN TABLE History 0|0|0|USE TEMP B-TREE FOR ORDER BY sqlite> explain query plan select url, title, strftime('%Y-%m-%d', last_atime, 'unixepoch') from CompletionHistory where (url like "%qute%" or title like "%qute%") order by last_atime desc; 0|0|0|SCAN TABLE CompletionHistory 0|0|0|USE TEMP B-TREE FOR ORDER BY after ----- sqlite> SELECT * FROM History where not redirect and not url like "qute://%" and atime > ? and atime <= ? ORDER BY atime desc; Run Time: real 0.000 user 0.000000 sys 0.000000 sqlite> explain query plan SELECT * FROM History where not redirect and not url like "qute://%" and atime > ? and atime <= ? ORDER BY atime desc; 0|0|0|SEARCH TABLE History USING INDEX AtimeIndex (atime>? AND atime explain query plan select url, title, strftime('%Y-%m-%d', last_atime, 'unixepoch') from CompletionHistory where (url like "%qute%" or title like "%qute%") order by last_atime desc; 0|0|0|SCAN TABLE CompletionHistory USING INDEX CompletionAtimeIndex --- qutebrowser/browser/history.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qutebrowser/browser/history.py b/qutebrowser/browser/history.py index 62c773866..05f2fefd5 100644 --- a/qutebrowser/browser/history.py +++ b/qutebrowser/browser/history.py @@ -79,6 +79,7 @@ class CompletionHistory(sql.SqlTable): def __init__(self, parent=None): super().__init__("CompletionHistory", ['url', 'title', 'last_atime'], constraints={'url': 'PRIMARY KEY'}, parent=parent) + self.create_index('CompletionHistoryAtimeIndex', 'last_atime') class WebHistory(sql.SqlTable): @@ -90,6 +91,7 @@ class WebHistory(sql.SqlTable): parent=parent) self.completion = CompletionHistory(parent=self) self.create_index('HistoryIndex', 'url') + self.create_index('HistoryAtimeIndex', 'atime') self._contains_query = self.contains_query('url') self._between_query = sql.Query('SELECT * FROM History ' 'where not redirect '