Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Add a few indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
S7evinK committed Mar 5, 2024
1 parent f2358c5 commit aece4c3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions roomserver/storage/postgres/events_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ CREATE TABLE IF NOT EXISTS roomserver_events (
-- Create an index which helps in resolving membership events (event_type_nid = 5) - (used for history visibility)
CREATE INDEX IF NOT EXISTS roomserver_events_memberships_idx ON roomserver_events (room_nid, event_state_key_nid) WHERE (event_type_nid = 5);
-- The following indexes are used by bulkSelectStateEventByNIDSQL
CREATE INDEX IF NOT EXISTS roomserver_event_event_type_nid_idx ON roomserver_events (event_type_nid);
CREATE INDEX IF NOT EXISTS roomserver_event_state_key_nid_idx ON roomserver_events (event_state_key_nid);
`

const insertEventSQL = "" +
Expand Down
8 changes: 8 additions & 0 deletions roomserver/storage/sqlite3/events_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ const eventsSchema = `
auth_event_nids TEXT NOT NULL DEFAULT '[]',
is_rejected BOOLEAN NOT NULL DEFAULT FALSE
);
-- Create an index which helps in resolving membership events (event_type_nid = 5) - (used for history visibility)
CREATE INDEX IF NOT EXISTS roomserver_events_memberships_idx ON roomserver_events (room_nid, event_state_key_nid) WHERE (event_type_nid = 5);
-- The following indexes are used by bulkSelectStateEventByNIDSQL
CREATE INDEX IF NOT EXISTS roomserver_event_event_type_nid_idx ON roomserver_events (event_type_nid);
CREATE INDEX IF NOT EXISTS roomserver_event_state_key_nid_idx ON roomserver_events (event_state_key_nid);
`

const insertEventSQL = `
Expand Down

0 comments on commit aece4c3

Please sign in to comment.