Database guides
Tooling
- Understanding EXPLAIN plans
-
explain.depesz.com or explain.dalibo.com for visualizing the output of
EXPLAIN
- pgFormatter a PostgreSQL SQL syntax beautifier
Migrations
- What requires downtime?
- SQL guidelines for working with SQL queries
- Migrations style guide for creating safe SQL migrations
- Testing Rails migrations guide
- Post deployment migrations
- Background migrations
- Swapping tables
- Deleting migrations
Debugging
- Tracing the source of an SQL query using query comments with Marginalia
- Tracing the source of an SQL query in Rails console using Verbose Query Logs
Best practices
- Adding database indexes
- Foreign keys & associations
- Adding a foreign key constraint to an existing column
NOT NULL
constraints- Strings and the Text data type
- Single table inheritance
- Polymorphic associations
- Serializing data
- Hash indexes
- Storing SHA1 hashes as binary
- Iterating tables in batches
- Insert into tables in batches
- Ordering table columns
- Verifying database capabilities
- Database Debugging and Troubleshooting
- Query Count Limits
- Creating enums