Measure query speed with Postgres’ EXPLAIN ANALYZE.
Some tips on how to do many-to-many SQL queries without a normal join table.
A look at the Postgres array type and good old join tables, each with their advantages and disadvantages.
Re-use collection query logic within model instances to avoid duplication and get the best performance.
You probably use some type of error monitoring software to notify you when an exception is raised in your application, but are you being notified when there is an anomaly in user behavior?
How do you even save a “duration”, let alone query for records by that value? It’s actually easier than you think.
A quick introduction to which database index types are right for the task at hand in Postgresql.
Finally, you too can understand how to use GROUP BY in your SQL queries.
A mental model to understand SQL’s JOIN.
See WHERE and SELECT visualized in this SQL primer.