2
Question
How can I calculate monthly retention cohorts in PostgreSQL?
I have an accounts table with created_at and an events table with account_id and occurred_at. I need a matrix where each row is a signup month and columns show the percentage active in months 0–6.
The event table has roughly 40 million rows. A query shape and indexing advice would both help.