Improving Eloquent Subquery Performance in Reimpact Platform
Introduction
We were experiencing slow query times in the Reimpact platform when using Eloquent subqueries with anonymous models. The issue stemmed from unintended default ordering and a mismatch between the model table and the subquery alias.
The Problem
Eloquent was automatically adding an ORDER BY pulse_entries.id clause, even though `pulse_entries.