Cache SQL statements for reactions/attachment fetches

This commit is contained in:
Pete Walters 2024-10-22 13:34:45 -05:00 committed by GitHub
parent 9956bd3ce0
commit 315f2ebbd1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 3 deletions

View File

@ -76,8 +76,8 @@ public class AttachmentStoreImpl: AttachmentStore {
}
let sql = "SELECT * FROM \(recordType.databaseTableName) WHERE \(filterClauses.joined(separator: " OR "));"
do {
var results = try RecordType
.fetchAll(tx.databaseConnection, sql: sql, arguments: arguments)
let statement = try tx.databaseConnection.cachedStatement(sql: sql)
var results = try RecordType.fetchAll(statement, arguments: arguments)
// If we have one owner and are capable of sorting, sort in ascending order.
if owners.count == 1, let orderInOwnerKey = RecordType.orderInOwnerKey {

View File

@ -71,7 +71,8 @@ public class ReactionFinder {
var reactions = [OWSReaction]()
do {
let cursor = try OWSReaction.fetchCursor(transaction.database, sql: sql, arguments: [uniqueMessageId])
let statement = try transaction.database.cachedStatement(sql: sql)
let cursor = try OWSReaction.fetchCursor(statement, arguments: [uniqueMessageId])
while let reaction = try cursor.next() {
reactions.append(reaction)
}