mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-20 10:33:41 -05:00
hicli/database: add missing indexes for fast room deletes
This commit is contained in:
parent
6f3619f632
commit
a79c249688
2 changed files with 7 additions and 2 deletions
|
@ -1,4 +1,4 @@
|
|||
-- v0 -> v7 (compatible with v5+): Latest revision
|
||||
-- v0 -> v8 (compatible with v5+): Latest revision
|
||||
CREATE TABLE account (
|
||||
user_id TEXT NOT NULL PRIMARY KEY,
|
||||
device_id TEXT NOT NULL,
|
||||
|
@ -37,6 +37,7 @@ CREATE TABLE room (
|
|||
) STRICT;
|
||||
CREATE INDEX room_type_idx ON room (creation_content ->> 'type');
|
||||
CREATE INDEX room_sorting_timestamp_idx ON room (sorting_timestamp DESC);
|
||||
CREATE INDEX room_preview_idx ON room (preview_event_rowid);
|
||||
-- CREATE INDEX room_sorting_timestamp_idx ON room (unread_notifications > 0);
|
||||
-- CREATE INDEX room_sorting_timestamp_idx ON room (unread_messages > 0);
|
||||
|
||||
|
@ -248,7 +249,8 @@ CREATE TABLE current_state (
|
|||
|
||||
PRIMARY KEY (room_id, event_type, state_key),
|
||||
CONSTRAINT current_state_room_fkey FOREIGN KEY (room_id) REFERENCES room (room_id) ON DELETE CASCADE,
|
||||
CONSTRAINT current_state_event_fkey FOREIGN KEY (event_rowid) REFERENCES event (rowid)
|
||||
CONSTRAINT current_state_event_fkey FOREIGN KEY (event_rowid) REFERENCES event (rowid),
|
||||
CONSTRAINT current_state_rowid_unique UNIQUE (event_rowid)
|
||||
) STRICT, WITHOUT ROWID;
|
||||
|
||||
CREATE TABLE receipt (
|
||||
|
|
3
pkg/hicli/database/upgrades/08-add-missing-indexes.sql
Normal file
3
pkg/hicli/database/upgrades/08-add-missing-indexes.sql
Normal file
|
@ -0,0 +1,3 @@
|
|||
-- v8 (compatible with v5+): Add indexes necessary for fast room deletion
|
||||
CREATE INDEX room_preview_idx ON room (preview_event_rowid);
|
||||
CREATE UNIQUE INDEX current_state_rowid_unique ON current_state (event_rowid);
|
Loading…
Add table
Reference in a new issue