aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2020-06-09 21:46:49 +0100
committerChristopher Baines <mail@cbaines.net>2020-06-13 16:02:59 +0100
commit7f71d9b7ce33ffbe7102061a11ebb78d47c315b4 (patch)
tree7d41f0db82ec92960bb4741ea11fa64ec34c592a
parent2280ae18eb25aa7034636c58bf288c9bd5a8fa3b (diff)
downloadcuirass-7f71d9b7ce33ffbe7102061a11ebb78d47c315b4.tar
cuirass-7f71d9b7ce33ffbe7102061a11ebb78d47c315b4.tar.gz
sql: Add a couple of indexes.
Remove the Builds_index from the schema, as it would have been removed in error by the upgrade-6 upgrade. Add a specific index on the Builds status field, as this helps with db-get-builds queries, and add an index on the Outputs derivation field, as this helps with the db-get-outputs part of db-get-builds. * src/sql/upgrade-8.sql: New file. * src/schema.sql: Update accordingly.
-rw-r--r--src/schema.sql3
-rw-r--r--src/sql/upgrade-8.sql7
2 files changed, 9 insertions, 1 deletions
diff --git a/src/schema.sql b/src/schema.sql
index 8ae0a85..5ea1ff7 100644
--- a/src/schema.sql
+++ b/src/schema.sql
@@ -85,7 +85,8 @@ CREATE TABLE Events (
-- Create indexes to speed up common queries, in particular those
-- corresponding to /api/latestbuilds and /api/queue HTTP requests.
-CREATE INDEX Builds_index ON Builds(job_name, system, status ASC, timestamp ASC, derivation, evaluation, stoptime DESC);
+CREATE INDEX Builds_status_index ON Builds (status);
+CREATE INDEX Outputs_derivation_index ON Outputs (derivation);
CREATE INDEX Inputs_index ON Inputs(specification, name, branch);
COMMIT;
diff --git a/src/sql/upgrade-8.sql b/src/sql/upgrade-8.sql
new file mode 100644
index 0000000..1be3470
--- /dev/null
+++ b/src/sql/upgrade-8.sql
@@ -0,0 +1,7 @@
+BEGIN TRANSACTION;
+
+CREATE INDEX Builds_status_index ON Builds (status);
+
+CREATE INDEX Outputs_derivation_index ON Outputs (derivation);
+
+COMMIT;