disable counts for regex queries, it is performance killer sadly

This commit is contained in:
Martin Rotter 2023-09-06 10:29:16 +02:00
parent 741d1b2b45
commit a4f3786e01
3 changed files with 3 additions and 42 deletions

View File

@ -84,28 +84,11 @@ bool Search::deleteViaGui() {
}
void Search::updateCounts(bool including_total_count) {
QSqlDatabase database = qApp->database()->driver()->threadSafeConnection(metaObject()->className());
int account_id = getParentServiceRoot()->accountId();
Q_UNUSED(including_total_count)
try {
auto ac = DatabaseQueries::getMessageCountsForProbe(database, this, account_id);
if (including_total_count) {
setCountOfAllMessages(ac.m_total);
}
setCountOfUnreadMessages(ac.m_unread);
}
catch (const ApplicationException& ex) {
qCriticalNN << LOGSEC_CORE << "Failed to get counts of probe:" << QUOTE_W_SPACE_DOT(ex.message());
if (including_total_count) {
setCountOfAllMessages(-1);
}
setCountOfUnreadMessages(-1);
}
}
QList<Message> Search::undeletedMessages() const {
QSqlDatabase database = qApp->database()->driver()->connection(metaObject()->className());

View File

@ -60,27 +60,6 @@ QList<QAction*> SearchsNode::contextMenuFeedsList() {
return QList<QAction*>{m_actProbeNew};
}
void SearchsNode::updateCounts(bool including_total_count) {
Q_UNUSED(including_total_count)
// NOTE: We do not update all counts here because it is simply taking too much time.
// This is true when user has many regex queries added because SQLite (MariaDB) simply
// takes too long to finish SQL queries with REGEXPs.
//
// We only update one by one.
if (childCount() <= 10) {
RootItem::updateCounts(including_total_count);
}
else {
for (RootItem* child : qAsConst(childItems())) {
auto* sear = qobject_cast<Search*>(child);
sear->setCountOfAllMessages(-1);
sear->setCountOfUnreadMessages(-1);
}
}
}
void SearchsNode::createProbe() {
FormAddEditProbe frm(qApp->mainFormWidget());
Search* new_prb = frm.execForAdd();

View File

@ -18,7 +18,6 @@ class SearchsNode : public RootItem {
virtual QList<Message> undeletedMessages() const;
virtual QList<QAction*> contextMenuFeedsList();
virtual void updateCounts(bool including_total_count);
Search* probeById(const QString& custom_id);