spree/spree — pull request #5453 by mbj (2014-10-06 23:13:49+00:00)
Title: Refactor Promotion.applied scope to query faster

Before the scope did two joins. Joining the join table and than the orders table. As joining the join table is sufficient to define the result set removing one layer of joins significantly speeds up the operation on large order tables.

In our case it reduced the time to render `/admin` with the order index from 4sec to around 2seconds. (Yeah big orders table).

Most likely this is also helpful for other spree bigger installations.