mirror of
https://github.com/coder/coder.git
synced 2026-06-03 04:58:23 +00:00
perf(coderd/database): optimize GetAPIKeysLastUsedAfter (#19725)
This change adds a support-index for `GetAPIKeysLastUsedAfter`. On dogfood (24h): called 4.4k times, 380ms average. Change for tested time range: `170ms` -> `3.3ms`.
This commit is contained in:
committed by
GitHub
parent
fb9753edf2
commit
21402c7aaa
Generated
+4
@@ -2861,6 +2861,10 @@ ALTER TABLE ONLY workspace_resources
|
||||
ALTER TABLE ONLY workspaces
|
||||
ADD CONSTRAINT workspaces_pkey PRIMARY KEY (id);
|
||||
|
||||
CREATE INDEX api_keys_last_used_idx ON api_keys USING btree (last_used DESC);
|
||||
|
||||
COMMENT ON INDEX api_keys_last_used_idx IS 'Index for optimizing api_keys queries filtering by last_used';
|
||||
|
||||
CREATE INDEX idx_agent_stats_created_at ON workspace_agent_stats USING btree (created_at);
|
||||
|
||||
CREATE INDEX idx_agent_stats_user_id ON workspace_agent_stats USING btree (user_id);
|
||||
|
||||
Reference in New Issue
Block a user