Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- Restores the index set from 001.
CREATE INDEX IF NOT EXISTS sessions_username_idx ON sessions USING btree (username);

--bun:split

CREATE INDEX IF NOT EXISTS sessions_type_idx ON sessions USING btree (type);

--bun:split

CREATE INDEX IF NOT EXISTS sessions_closed_started_idx ON sessions USING btree (closed, started_at);
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-- Three indexes from 001 that no query in either repo can reach, maintained on every session
-- insert and update for nothing. IF EXISTS because operators may already have dropped them by
-- hand, and an error here fails the boot.
--
-- There is no read-path trade to weigh: these back no filter, no sort and no constraint, so
-- nothing gets slower.

-- The session list accepts exactly three filter fields (device_uid, closed, active) and
-- rejects anything else at the route, and its sort is hardcoded to started_at — username is
-- reachable by neither.
DROP INDEX IF EXISTS sessions_username_idx;

--bun:split

-- Same for type. The type predicates that do exist are all on session_events, a different
-- table, and are already served by its session_id/seat indexes.
DROP INDEX IF EXISTS sessions_type_idx;

--bun:split

-- Redundant rather than merely unused: closed is a near-constant (a session is closed for all
-- but the few minutes it is live), so (closed, started_at) is a strictly fatter duplicate of
-- sessions_started_at_idx and loses to it on cost for every shape that exists — including the
-- one it looks tailor-made for, the recording-conversion worker's
-- "WHERE closed AND recorded AND NOT converted ORDER BY started_at DESC". If that worker ever
-- shows up as a cost, the index it wants is a partial one on the backlog alone, not this.
DROP INDEX IF EXISTS sessions_closed_started_idx;
Loading