Closed irees closed 8 years ago
Use of a CTE query for sorting (https://www.postgresql.org/docs/current/static/queries-with.html) can improve performance substantially -- tested with a local dump of prod db. The postgres_ext
(https://github.com/DockYard/postgres_ext/blob/master/docs/querying.md) gem adds this support, but it appears to have a conflict with squeel
. Investigating.
Perhaps of use: CTE support in ARel https://github.com/rails/arel#complex-joins ?
This is the query that was taking longer than 2 minutes to complete previously: https://transit.land/api/v1/schedule_stop_pairs?feed_onestop_id=f-drt8-nps~boha~ferries
After @irees 's index changes, it's nice and fast.
The ordering on most SSP queries can be very slow.