From 4deabceb9e1928b6b55c95db37dec0aa384ec2f7 Mon Sep 17 00:00:00 2001 From: Graham Date: Sun, 14 Mar 2021 10:20:52 +0000 Subject: [PATCH] Move container_id to the end of the groups index I think this will speed up the collisions view. Signed-off-by: Graham --- .../kotlin/org/openrs2/archive/cache/CacheImporter.kt | 8 ++++---- .../resources/org/openrs2/archive/migrations/V1__init.sql | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/archive/src/main/kotlin/org/openrs2/archive/cache/CacheImporter.kt b/archive/src/main/kotlin/org/openrs2/archive/cache/CacheImporter.kt index 3f5662833e..5cbbd15216 100644 --- a/archive/src/main/kotlin/org/openrs2/archive/cache/CacheImporter.kt +++ b/archive/src/main/kotlin/org/openrs2/archive/cache/CacheImporter.kt @@ -552,7 +552,7 @@ public class CacheImporter @Inject constructor( connection.prepareStatement( """ - INSERT INTO groups (archive_id, group_id, container_id, version, version_truncated) + INSERT INTO groups (archive_id, group_id, version, version_truncated, container_id) VALUES (?, ?, ?, ?, ?) ON CONFLICT DO NOTHING """.trimIndent() @@ -560,9 +560,9 @@ public class CacheImporter @Inject constructor( for ((i, group) in groups.withIndex()) { stmt.setInt(1, group.archive) stmt.setInt(2, group.group) - stmt.setLong(3, containerIds[i]) - stmt.setInt(4, group.version) - stmt.setBoolean(5, group.versionTruncated) + stmt.setInt(3, group.version) + stmt.setBoolean(4, group.versionTruncated) + stmt.setLong(5, containerIds[i]) stmt.addBatch() } diff --git a/archive/src/main/resources/org/openrs2/archive/migrations/V1__init.sql b/archive/src/main/resources/org/openrs2/archive/migrations/V1__init.sql index b496883b49..f9eec7cd9b 100644 --- a/archive/src/main/resources/org/openrs2/archive/migrations/V1__init.sql +++ b/archive/src/main/resources/org/openrs2/archive/migrations/V1__init.sql @@ -58,10 +58,10 @@ VALUES (NULL, NULL); CREATE TABLE groups ( archive_id uint1 NOT NULL, group_id INTEGER NOT NULL, - container_id BIGINT NOT NULL REFERENCES containers (id), version INTEGER NOT NULL, version_truncated BOOLEAN NOT NULL, - PRIMARY KEY (archive_id, group_id, container_id, version, version_truncated) + container_id BIGINT NOT NULL REFERENCES containers (id), + PRIMARY KEY (archive_id, group_id, version, version_truncated, container_id) ); CREATE TABLE indexes (