osu-web icon indicating copy to clipboard operation
osu-web copied to clipboard

Faster multiplayer room participation listing

Open notbakaneko opened this issue 8 months ago • 8 comments

Duplicates ends_at to multiplayer_rooms_high and uses it for sort order. The existing issue is ordering on multiplayer_rooms while the existence check uses multiplayer_rooms_high can result in too many records being scanned to get enough matching rows. The issue doesn't exist if there's no sort order, or the required rows are all early in the sorting order.

I made the listing a separate scope so other queries that don't have the issue can skip the join mess.

  • [ ] add migration 2024_06_11_000001_add_ends_at_to_multiplayer_rooms_high
  • [ ] CREATE INDEX participated_rooms ON multiplayer_rooms_high (ends_at DESC, room_id DESC, user_id)
  • [ ] fill column UPDATE multiplayer_rooms_high h INNER JOIN multiplayer_rooms r ON h.room_id = r.id SET h.ends_at = r.ends_at

notbakaneko avatar Jun 11 '24 15:06 notbakaneko