From bc0213c9a10922c63da0f2b0a90e89e591ab80cd Mon Sep 17 00:00:00 2001 From: Noko Date: Sat, 5 Oct 2019 15:30:55 -0500 Subject: [PATCH] Added indexes to support frontpercent query changes Note: need to determine conventions to use for index names and settings going forward. There are also some indexes in production that aren't in here and are probably good additions to a standard set. --- PluralKit.Core/db_schema.sql | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/PluralKit.Core/db_schema.sql b/PluralKit.Core/db_schema.sql index 3fe1848d..d0108cca 100644 --- a/PluralKit.Core/db_schema.sql +++ b/PluralKit.Core/db_schema.sql @@ -49,6 +49,10 @@ create table if not exists switches system serial not null references systems (id) on delete cascade, timestamp timestamp not null default (current_timestamp at time zone 'utc') ); +CREATE INDEX IF NOT EXISTS idx_switches_system +ON switches USING btree ( + system ASC NULLS LAST +) INCLUDE ("timestamp"); create table if not exists switch_members ( @@ -56,6 +60,10 @@ create table if not exists switch_members switch serial not null references switches (id) on delete cascade, member serial not null references members (id) on delete cascade ); +CREATE INDEX IF NOT EXISTS idx_switch_members_switch +ON switch_members USING btree ( + switch ASC NULLS LAST +) INCLUDE (member); create table if not exists webhooks (