Skip to content

Commit

Permalink
db: add back indices
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hermankolden committed Jun 30, 2024
1 parent c6cbd33 commit 3d506dc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyulog/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
17 changes: 17 additions & 0 deletions pyulog/sql/pyulog.5.sql
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 3d506dc

Please sign in to comment.