diff --git a/data/Data.cpp b/data/Data.cpp index 5436e64d..b7815b84 100644 --- a/data/Data.cpp +++ b/data/Data.cpp @@ -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; diff --git a/res/sql/migration_008.sql b/res/sql/migration_008.sql index 52ef7621..c89ed629 100644 --- a/res/sql/migration_008.sql +++ b/res/sql/migration_008.sql @@ -13,3 +13,7 @@ CREATE TABLE IF NOT EXISTS alert_rules spotter_country INTEGER, spotter_continent TEXT ); + +CREATE INDEX "dxcc_idx" ON "contacts" ( + "dxcc" +);