SQL Practice Logo

SQLPractice Online

Level 6 - ExpertOptimization Questionsm4 domain design cases

Optimization: Cohort Query Pattern

Choose the better query for monthly signup cohort counts. Query A: SELECT DATE_TRUNC('month', created_at) m, COUNT(*) FROM users GROUP BY DATE_TRUNC('month', created_at); Query B: SELECT cohort_month, COUNT(*) FROM user_cohorts GROUP BY cohort_month;