From a2708132218f56bc6c0c9d9aab175b9117b22c60 Mon Sep 17 00:00:00 2001 From: Nikos Kouremenos Date: Sat, 7 Oct 2006 10:08:38 +0000 Subject: [PATCH] [patrys & me] logs db now uses indeces that makes the UI XP faster --- src/common/check_paths.py | 36 +++++++++++++++++++++++------------- src/gajim.py | 9 ++++++++- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/common/check_paths.py b/src/common/check_paths.py index a6bc52bf1..bff55d368 100644 --- a/src/common/check_paths.py +++ b/src/common/check_paths.py @@ -1,16 +1,7 @@ -## Contributors for this file: -## - Yann Le Boulanger -## - Nikos Kouremenos -## - Travis Shirk ## -## Copyright (C) 2003-2004 Yann Le Boulanger -## Vincent Hanquez -## Copyright (C) 2005 Yann Le Boulanger -## Vincent Hanquez -## Nikos Kouremenos -## Dimitur Kirov -## Travis Shirk -## Norman Rasmussen +## Copyright (C) 2005-2006 Yann Le Boulanger +## Copyright (C) 2005-2006 Nikos Kouremenos +## Copyright (C) 2005-2006 Travis Shirk ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published @@ -57,11 +48,13 @@ def create_log_db(): jid_id INTEGER ); + CREATE INDEX idx_unread_messages_jid_id ON unread_messages (jid_id); + CREATE TABLE transports_cache ( transport TEXT UNIQUE, type INTEGER ); - + CREATE TABLE logs( log_line_id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, jid_id INTEGER, @@ -72,6 +65,8 @@ def create_log_db(): message TEXT, subject TEXT ); + + CREATE INDEX idx_logs_jid_id_kind ON logs (jid_id, kind); ''' ) @@ -125,6 +120,21 @@ def check_and_possibly_create_paths(): create_log_db() gajim.logger.init_vars() +def migrate_logs_db_to_indeces(): + print _('migrating logs database to indeces') + con = sqlite.connect(logger.LOG_DB_PATH) + cur = con.cursor() + # apply indeces + cur.executescript( + ''' + CREATE INDEX IF NOT EXISTS idx_logs_jid_id_kind ON logs (jid_id, kind); + CREATE INDEX idx_unread_messages_jid_id ON unread_messages (jid_id); + ''' + ) + + con.commit() + con.close() + def create_path(directory): print _('creating %s directory') % directory os.mkdir(directory, 0700) diff --git a/src/gajim.py b/src/gajim.py index 01614f948..5d4da4457 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -1980,7 +1980,8 @@ if __name__ == '__main__': cli = gnome.ui.master_client() cli.connect('die', die_cb) - path_to_gajim_script = gtkgui_helpers.get_abspath_for_script('gajim') + path_to_gajim_script = gtkgui_helpers.get_abspath_for_script( + 'gajim') if path_to_gajim_script: argv = [path_to_gajim_script] @@ -1995,5 +1996,11 @@ if __name__ == '__main__': gtkgui_helpers.possibly_set_gajim_as_xmpp_handler() check_paths.check_and_possibly_create_paths() + + #FIXME: when .14 is out, remove this :D + if gajim.config.get('version') <= '0.10.1.3': + gajim.config.set('version', '0.10.1.4') + check_paths.migrate_logs_db_to_indeces() + Interface() gtk.main()