stats: Fix a slow query.