From 5704a49c7908cef401d23879f32013f90d2e7878 Mon Sep 17 00:00:00 2001
From: Tom Smeding <tom.smeding@gmail.com>
Date: Sat, 27 Jun 2020 22:16:53 +0200
Subject: server: Ensure db queries are all indexed

---
 schema.sql | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

(limited to 'schema.sql')

diff --git a/schema.sql b/schema.sql
index 06baafd..15d274c 100644
--- a/schema.sql
+++ b/schema.sql
@@ -17,6 +17,7 @@ create table Members (
 	foreign key(room) references Rooms(id) on delete cascade,
 	foreign key(user) references Users(id) on delete cascade
 );
+create index members_user_index on Members(user);
 
 create table Users (
 	id integer primary key not null,
@@ -34,7 +35,7 @@ create table Messages (
 	foreign key(room) references Rooms(id) on delete cascade,
 	foreign key(user) references Users(id) on delete set null
 );
-create index messages_time_index on Messages(time);
+create index messages_time_index on Messages(room, time desc);
 
 create table Firebase (
 	user integer not null,
-- 
cgit v1.2.3-54-g00ecf

