Write per_user_features(db): return rows of (user, order_count, total) for ALL users, sorted by user. This is the aggregate-in-the-database move — the groupby pushed down to where the data lives.
Write per_user_features(db): return rows of (user, order_count, total) for ALL users, sorted by user. This is the aggregate-in-the-database move — the groupby pushed down to where the data lives.