Log statistics about the SDSKeyValueStore on internal app launch
(without blocking launch, of course) This should help us identify which SDSKeyValueStore collections might be better promoted to full tables.
This commit is contained in:
parent
6e77f78e77
commit
2f710ecc87
@ -235,6 +235,11 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
backgroundTask = nil;
|
||||
}];
|
||||
});
|
||||
|
||||
// Do this after we've let the main thread know that storage setup is complete.
|
||||
if (SSKDebugFlags.internalLogging) {
|
||||
[SDSKeyValueStore logCollectionStatistics];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2021 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2022 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@ -63,6 +63,29 @@ public class SDSKeyValueStore: NSObject {
|
||||
try statement.execute()
|
||||
}
|
||||
|
||||
@objc
|
||||
public class func logCollectionStatistics() {
|
||||
Logger.info("SDSKeyValueStore statistics:")
|
||||
databaseStorage.read { transaction in
|
||||
do {
|
||||
let sql = """
|
||||
SELECT \(collectionColumn.columnName), COUNT(*)
|
||||
FROM \(table.tableName)
|
||||
GROUP BY \(collectionColumn.columnName)
|
||||
ORDER BY COUNT(*) DESC
|
||||
"""
|
||||
let cursor = try Row.fetchCursor(transaction.unwrapGrdbRead.database, sql: sql)
|
||||
while let row = try cursor.next() {
|
||||
let collection: String = row[0]
|
||||
let count: UInt = row[1]
|
||||
Logger.info("- \(collection): \(count) items")
|
||||
}
|
||||
} catch {
|
||||
Logger.error("\(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Class Helpers
|
||||
|
||||
@objc
|
||||
|
||||
Loading…
Reference in New Issue
Block a user