Skip to content

Commit

Permalink
Fix indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
sdsantos committed Dec 18, 2024
1 parent 49a93af commit 55a4077
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 25 deletions.
6 changes: 1 addition & 5 deletions composeApp/src/commonMain/sqldelight/migrations/7.sqm
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,5 @@ CREATE INDEX idx_result_test_name ON Result (test_group_name);
CREATE INDEX idx_result_descriptor ON Result (descriptor_runId);
CREATE INDEX idx_result_task_origin ON Result (task_origin);

CREATE INDEX idx_measure_start_time ON Measurement (start_time);
CREATE INDEX idx_measure_is_done ON Measurement (is_done);
CREATE INDEX idx_measure_is_uploaded ON Measurement (is_uploaded);
CREATE INDEX idx_measure_report_id ON Measurement (report_id);
CREATE INDEX idx_measure_is_upload_failed ON Measurement (is_upload_failed);
CREATE INDEX idx_measure_result_id ON Measurement (result_id);
CREATE INDEX idx_measure_start_time ON Measurement (start_time);
13 changes: 11 additions & 2 deletions composeApp/src/commonMain/sqldelight/migrations/8.sqm
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
CREATE INDEX idx_measure_is_failed ON Measurement (is_failed);
CREATE INDEX idx_measure_is_anomaly ON Measurement (is_anomaly);
CREATE TABLE NetworkTemporary(
id INTEGER PRIMARY KEY AUTOINCREMENT,
network_name TEXT,
asn TEXT,
country_code TEXT,
network_type TEXT
);

INSERT INTO NetworkTemporary SELECT id, network_name, asn, country_code, network_type FROM Network;
DROP TABLE Network;
ALTER TABLE NetworkTemporary RENAME TO Network;
16 changes: 0 additions & 16 deletions composeApp/src/commonMain/sqldelight/migrations/9.sqm

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ CREATE TABLE Measurement(
FOREIGN KEY(`result_id`) REFERENCES Result(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION
);

CREATE INDEX idx_measure_result_id ON Measurement (result_id);
CREATE INDEX idx_measure_start_time ON Measurement (start_time);

insertOrReplace:
INSERT OR REPLACE INTO Measurement (
id,
Expand Down Expand Up @@ -60,7 +63,8 @@ SELECT * FROM Measurement;
selectByResultIdWithUrl:
SELECT * FROM Measurement
LEFT JOIN Url ON Measurement.url_id = Url.id
WHERE Measurement.result_id = ?;
WHERE Measurement.result_id = ?
ORDER BY Measurement.start_time ASC;

selectAllNotUploaded:
SELECT * FROM Measurement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ CREATE TABLE Result(
FOREIGN KEY(`network_id`) REFERENCES Network(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION
);

CREATE INDEX idx_result_start_time ON Result (start_time);
CREATE INDEX idx_result_test_name ON Result (test_group_name);
CREATE INDEX idx_result_descriptor ON Result (descriptor_runId);
CREATE INDEX idx_result_task_origin ON Result (task_origin);

insertOrReplace:
INSERT OR REPLACE INTO Result (
id,
Expand Down Expand Up @@ -62,7 +67,6 @@ FROM (
MAX(Result.descriptor_runId) AS descriptor_runId,
MAX(Network.id) AS network_id_inner,
MAX(Network.network_name) AS network_name,
MAX(Network.ip) AS ip,
MAX(Network.asn) AS asn,
MAX(Network.country_code) AS country_code,
MAX(Network.network_type) AS network_type,
Expand Down

0 comments on commit 55a4077

Please sign in to comment.