Ecto: avoid to have to use a fragment twice (in select and group_by)

FWIW, even though it feels like “repeating yourself” Postgres will only calculate that fragment value once even if it’s used in both SELECT and GROUP BY - it’ll even fail if the expression isn’t identical.

For instance, see this discussion where the same column was interpolated as two separate placeholders and angered the query planner:

1 Like