From f7566bd00e687df60fd470b9fdfc5ce6b04f0c7c Mon Sep 17 00:00:00 2001
From: Holger Weiss <holger@zedat.fu-berlin.de>
Date: Sat, 24 Feb 2018 00:50:20 +0100
Subject: sql/*: Add username to peer indexes

The username is available for all MAM queries in question, and adding it
to the indexes can improve the lookup performance significantly.
---
 sql/mysql.new.sql | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'sql/mysql.new.sql')

diff --git a/sql/mysql.new.sql b/sql/mysql.new.sql
index c155794ee..9dafe5bb2 100644
--- a/sql/mysql.new.sql
+++ b/sql/mysql.new.sql
@@ -113,10 +113,10 @@ CREATE TABLE archive (
 ) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
 
 CREATE FULLTEXT INDEX i_text ON archive(txt);
-CREATE INDEX i_archive_sh_username_timestamp USING BTREE ON archive(server_host(191), username,timestamp);
+CREATE INDEX i_archive_sh_username_timestamp USING BTREE ON archive(server_host(191), username, timestamp);
+CREATE INDEX i_archive_sh_username_peer USING BTREE ON archive(server_host(191), username, peer);
+CREATE INDEX i_archive_sh_username_bare_peer USING BTREE ON archive(server_host(191), username, bare_peer);
 CREATE INDEX i_archive_sh_timestamp USING BTREE ON archive(server_host(191), timestamp);
-CREATE INDEX i_archive_sh_peer USING BTREE ON archive(server_host(191), peer);
-CREATE INDEX i_archive_sh_bare_peer USING BTREE ON archive(server_host(191), bare_peer);
 
 CREATE TABLE archive_prefs (
     username varchar(191) NOT NULL,
-- 
cgit v1.2.3

