https://github.com/getsentry/sentry
Here's all the database models:
https://github.com/getsentry/sentry/tree/master/src/sentry/m...
Here's an example of hacks in the form of massive caching to improve performance:
https://github.com/getsentry/sentry/blob/master/src/sentry/d...
There's a ton of DB passion at Sentry but most importantly for anyone this deep in the thread, Sentry also detects and helps fix common DB mistakes whether it's you or the ORM: https://docs.sentry.io/product/issues/issue-details/performa...
If you're at the “why it’s slow” runbook, Sentry turns the first 2 steps into 1 click: https://docs.sentry.io/product/performance/queries/
For anyone else, I also remember PostgresSQL manual/docs being very high quality, so that might be worth reading just to better grok SQL/relational DB topics.