otakulan/lanparty-seating

Optimize SQL query that fetches the status of every station

Closed this issue · 1 comments

In https://github.com/starcraft66/lanparty-seating/blob/master/lib/lanpartyseating/logic/station_logic.ex, we start by querying all of the stations in the repo on line 16, then for every station, we call get_station_status/1 on them which results in 3 SQL queries being executed per station. This is very expensive and causes the page to be noticeably slow even with postgres running on an SSD on localhost.

All of the logic in there needs to be refactored into a single SQL query that joins the Station with Reservation and TournamentReservation to find all of the stations and their status.

Completed in #34