Skip to content

Commit

Permalink
Fixing #52 - High CPU Load when a high traffic from DXC
Browse files Browse the repository at this point in the history
  • Loading branch information
foldynl committed May 4, 2022
1 parent 18fc2c2 commit 60f2d80
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions data/Data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ DxccStatus Data::dxccStatus(int dxcc, const QString &band, const QString &mode)

QSqlQuery query;

if ( ! query.prepare("SELECT (SELECT contacts.callsign FROM contacts WHERE dxcc = :dxcc " + filter + " ORDER BY start_time ASC LIMIT 1) as entity,"
"(SELECT contacts.callsign FROM contacts WHERE dxcc = :dxcc AND band = :band " + filter + " ORDER BY start_time ASC LIMIT 1) as band,"
if ( ! query.prepare("SELECT (SELECT contacts.callsign FROM contacts WHERE dxcc = :dxcc " + filter + " LIMIT 1) as entity,"
"(SELECT contacts.callsign FROM contacts WHERE dxcc = :dxcc AND band = :band " + filter + " LIMIT 1) as band,"
"(SELECT contacts.callsign FROM contacts INNER JOIN modes ON (modes.name = contacts.mode)"
" WHERE contacts.dxcc = :dxcc AND modes.dxcc = " + sql_mode + filter +
" ORDER BY start_time ASC LIMIT 1) as mode,"
" LIMIT 1) as mode,"
"(SELECT contacts.callsign FROM contacts INNER JOIN modes ON (modes.name = contacts.mode)"
" WHERE contacts.dxcc = :dxcc AND modes.dxcc = " + sql_mode + filter +
" AND band = :band ORDER BY start_time ASC LIMIT 1) as slot;") )
" AND band = :band LIMIT 1) as slot;") )
{
qWarning() << "Cannot prepare Select statement";
return DxccStatus::UnknownStatus;
Expand Down
4 changes: 4 additions & 0 deletions res/sql/migration_008.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ CREATE TABLE IF NOT EXISTS alert_rules
spotter_country INTEGER,
spotter_continent TEXT
);

CREATE INDEX "dxcc_idx" ON "contacts" (
"dxcc"
);

0 comments on commit 60f2d80

Please sign in to comment.