Skip to content

Commit

Permalink
Performance: cache some more queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Adams committed Sep 18, 2020
1 parent 8d25513 commit 0300c7f
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 198 deletions.
13 changes: 2 additions & 11 deletions src/engine/contactreader.cpp
Expand Up @@ -2560,21 +2560,12 @@ QContactManager::Error ContactReader::queryContacts(
detailQueryStatement = detailQueryStatement.arg(detailNameTemplate.arg(detailNameSpec.join(QLatin1String("','"))));

// If selectSpec is empty, all required details are in the Contacts table
QSqlQuery detailQuery(m_database);
ContactsDatabase::Query detailQuery(m_database.prepare(detailQueryStatement));
if (!selectSpec.isEmpty()) {
if (!detailQuery.prepare(detailQueryStatement)) {
QTCONTACTS_SQLITE_WARNING(QString::fromLatin1("Failed to prepare query for joined details:\n%1\nQuery:\n%2")
.arg(detailQuery.lastError().text())
.arg(detailQueryStatement));
return QContactManager::UnspecifiedError;
}

// Read the details for these contacts
detailQuery.setForwardOnly(true);
if (!ContactsDatabase::execute(detailQuery)) {
QTCONTACTS_SQLITE_WARNING(QString::fromLatin1("Failed to prepare query for joined details:\n%1\nQuery:\n%2")
.arg(detailQuery.lastError().text())
.arg(detailQueryStatement));
detailQuery.reportError(QString::fromLatin1("Failed to prepare query for joined details"));
return QContactManager::UnspecifiedError;
} else {
// Move to the first row
Expand Down

0 comments on commit 0300c7f

Please sign in to comment.