Create index on the logs table on time instead of on kind.

That way we can search through all logs in constant time instead of having to perform a full table scan.
This commit is contained in:
Stephan Erb 2009-12-27 16:50:43 +01:00
parent 54ad65c744
commit d00a5f737c
3 changed files with 25 additions and 2 deletions

View File

@ -79,7 +79,7 @@ def create_log_db():
subject TEXT
);
CREATE INDEX idx_logs_jid_id_kind ON logs (jid_id, kind);
CREATE INDEX idx_logs_jid_id_time ON logs (jid_id, time DESC);
CREATE TABLE caps_cache (
hash_method TEXT,

View File

@ -27,7 +27,7 @@ docdir = '../'
basedir = '../'
localedir = '../po'
version = '0.13.10.0-dev'
version = '0.13.10.1-dev'
import sys, os.path
for base in ('.', 'common'):

View File

@ -214,6 +214,8 @@ class OptionsParser:
self.update_config_to_01258()
if old < [0, 13, 10, 0] and new >= [0, 13, 10, 0]:
self.update_config_to_013100()
if old < [0, 13, 10, 1] and new >= [0, 13, 10, 1]:
self.update_config_to_013101()
gajim.logger.init_vars()
gajim.config.set('version', new_version)
@ -857,4 +859,25 @@ class OptionsParser:
con.close()
gajim.config.set('version', '0.13.10.0')
def update_config_to_013101(self):
back = os.getcwd()
os.chdir(logger.LOG_DB_FOLDER)
con = sqlite.connect(logger.LOG_DB_FILE)
os.chdir(back)
cur = con.cursor()
try:
cur.executescript(
'''
DROP INDEX IF EXISTS idx_logs_jid_id_kind;
CREATE INDEX IF NOT EXISTS
idx_logs_jid_id_time ON logs (jid_id, time DESC);
'''
)
con.commit()
except sqlite.OperationalError:
pass
con.close()
gajim.config.set('version', '0.13.10.1')
# vim: se ts=3: