Skip to content
Merged
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
17 changes: 17 additions & 0 deletions ddl/migrations/0220_saves_user_track_current_blocknumber_idx.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-- Supports /v1/users/:id/favorites pagination:
--
-- WHERE user_id = ?
-- AND is_delete = false
-- AND is_current = true
-- AND save_type = 'track'
-- ORDER BY blocknumber, save_item_id DESC
--
-- The existing saves_user_idx is ordered by save_item_id before is_delete and
-- cannot satisfy the endpoint's blocknumber ordering, which showed up in prod
-- pg_stat_statements with high total temp I/O.
CREATE INDEX CONCURRENTLY IF NOT EXISTS saves_user_track_current_blocknumber_idx
ON public.saves USING btree (user_id, blocknumber, save_item_id DESC)
INCLUDE (created_at)
WHERE save_type = 'track'
AND is_current = true
AND is_delete = false;
Loading