Create a SQL index on History.url.
This will hopefully speed up historyContains but does not seem to speed up the completion query, unfortunately.
This commit is contained in:
parent
565ba23f8c
commit
6a0fc5afd2
@ -78,6 +78,7 @@ class WebHistory(sql.SqlTable):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__("History", ['url', 'title', 'atime', 'redirect'],
|
||||
parent=parent)
|
||||
self.create_index('HistoryIndex', 'url', where='not redirect')
|
||||
self._between_query = sql.Query('SELECT * FROM History '
|
||||
'where not redirect '
|
||||
'and not url like "qute://%" '
|
||||
|
@ -122,6 +122,18 @@ class SqlTable(QObject):
|
||||
# pylint: disable=invalid-name
|
||||
self.Entry = collections.namedtuple(name + '_Entry', fields)
|
||||
|
||||
def create_index(self, name, field, where):
|
||||
"""Create an index over this table.
|
||||
|
||||
Args:
|
||||
name: Name of the index, should be unique.
|
||||
field: Name of the field to index.
|
||||
where: WHERE clause for a partial index.
|
||||
"""
|
||||
q = Query("CREATE INDEX IF NOT EXISTS {} ON {} ({}) WHERE {}"
|
||||
.format(name, self._name, field, where))
|
||||
q.run()
|
||||
|
||||
def __iter__(self):
|
||||
"""Iterate rows in the table."""
|
||||
q = Query("SELECT * FROM {}".format(self._name))
|
||||
|
Loading…
Reference in New Issue
Block a user