From 3d506dc8152070ec6b4adeaf9a03fc8636ad9c5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herman=20=C3=98ie=20Kolden?= Date: Sun, 30 Jun 2024 15:17:30 +0200 Subject: [PATCH] db: add back indices There were lost in pyulog.2.sql, so the DB is very slow for large databases. NB: Applying this migration will take a while for large databases. --- pyulog/db.py | 2 +- pyulog/sql/pyulog.5.sql | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 pyulog/sql/pyulog.5.sql diff --git a/pyulog/db.py b/pyulog/db.py index 6d14905..141becd 100644 --- a/pyulog/db.py +++ b/pyulog/db.py @@ -49,7 +49,7 @@ class DatabaseULog(ULog): contsructor will throw an exception. See the documentation of "ulog_migratedb" for more information. ''' - SCHEMA_VERSION = 4 + SCHEMA_VERSION = 5 @staticmethod def get_db_handle(db_path): diff --git a/pyulog/sql/pyulog.5.sql b/pyulog/sql/pyulog.5.sql new file mode 100644 index 0000000..42ca5bc --- /dev/null +++ b/pyulog/sql/pyulog.5.sql @@ -0,0 +1,17 @@ +BEGIN; +CREATE INDEX IF NOT EXISTS btree_ULogAppendedOffsets_ULogId ON ULogAppendedOffsets(ULogId); +CREATE INDEX IF NOT EXISTS btree_ULogDataset_ULogId ON ULogDataset(ULogId); +CREATE INDEX IF NOT EXISTS btree_ULogField_DatasetId ON ULogField(DatasetId); +CREATE INDEX IF NOT EXISTS btree_ULogMessageDropout_ULogId ON ULogMessageDropout(ULogId); +CREATE INDEX IF NOT EXISTS btree_ULogMessageFormat_ULogId ON ULogMessageFormat(ULogId); +CREATE INDEX IF NOT EXISTS btree_ULogMessageFormatField_MessageId ON ULogMessageFormatField(MessageId); +CREATE INDEX IF NOT EXISTS btree_ULogMessageLogging_ULogId ON ULogMessageLogging(ULogId); +CREATE INDEX IF NOT EXISTS btree_ULogMessageLoggingTagged_ULogId ON ULogMessageLoggingTagged(ULogId); +CREATE INDEX IF NOT EXISTS btree_ULogMessageInfo_ULogId ON ULogMessageInfo(ULogId); +CREATE INDEX IF NOT EXISTS btree_ULogMessageInfoMultiple_ULogId ON ULogMessageInfoMultiple(ULogId); +CREATE INDEX IF NOT EXISTS btree_ULogMessageInfoMultipleList_MessageId ON ULogMessageInfoMultipleList(MessageId); +CREATE INDEX IF NOT EXISTS btree_ULogMessageInfoMultipleListElement_ListId ON ULogMessageInfoMultipleListElement(ListId); +CREATE INDEX IF NOT EXISTS btree_ULogInitialParameter_ULogId ON ULogInitialParameter(ULogId); +CREATE INDEX IF NOT EXISTS btree_ULogChangedParameter_ULogId ON ULogChangedParameter(ULogId); +CREATE INDEX IF NOT EXISTS btree_ULogDefaultParameter_ULogId ON ULogDefaultParameter(ULogId); +COMMIT;