mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-06 16:02:23 +00:00
perf: add (workspace_id, email, created_at) partial index for sync hot path
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
ALTER TABLE draft DROP COLUMN id;
|
||||
|
||||
DROP INDEX IF EXISTS draft_user_sync_idx;
|
||||
DROP INDEX IF EXISTS draft_pkey_legacy;
|
||||
DROP INDEX IF EXISTS draft_pkey_with_user;
|
||||
|
||||
|
||||
@@ -61,4 +61,13 @@ CREATE UNIQUE INDEX draft_pkey_legacy
|
||||
ON draft (workspace_id, path, typ)
|
||||
WHERE email IS NULL;
|
||||
|
||||
-- Hot path for `sync_drafts`: each active editor polls
|
||||
-- `WHERE workspace_id = ? AND email = ? [AND created_at > ?]` every 2-10s.
|
||||
-- Neither partial unique index above helps (both lead with `path, typ`);
|
||||
-- this covers the initial sync (leading two columns) and the incremental
|
||||
-- missed-drafts query (range scan on `created_at`).
|
||||
CREATE INDEX draft_user_sync_idx
|
||||
ON draft (workspace_id, email, created_at)
|
||||
WHERE email IS NOT NULL;
|
||||
|
||||
ALTER TABLE draft ADD COLUMN id BIGSERIAL PRIMARY KEY;
|
||||
|
||||
Reference in New Issue
Block a user