4.5 KiB
4.5 KiB
stage | group | info |
---|---|---|
Data Stores | Database | To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments |
Database guides
Database Reviews
-
If you're creating a database MR for review, check out our Database review guidelines.
It provides an introduction on database-related changes, migrations, and complex SQL queries.
-
If you're a database reviewer or want to become one, check out our introduction to reviewing database changes.
Tooling
- Understanding EXPLAIN plans
- explain.depesz.com or explain.dalibo.com for visualizing the output of
EXPLAIN
- pgFormatter a PostgreSQL SQL syntax beautifier
- db:check-migrations job
Migrations
- Different types of migrations
- Create a regular migration, including creating new models
- Post-deployment migrations guidelines and how to create one
- Background migrations guidelines
- Batched background migrations guidelines
- Deleting migrations
- Running database migrations
- Migrations for multiple databases
- Avoiding downtime in migrations
- When and how to write Rails migrations tests
- Migrations style guide for creating safe SQL migrations
- Testing Rails migrations guide
- Post deployment migrations
- Background migrations
- Swapping tables
- Deleting migrations
- SQL guidelines for working with SQL queries
- Partitioning tables
Debugging
- Resetting the database
- Accessing the database
- Troubleshooting and debugging the database
- 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
- Query Count Limits
- Creating enums
- Client-side connection-pool
- Updating multiple values
- Constraints naming conventions
- Query performance guidelines
- Pagination guidelines
- Efficient
IN
operator queries - Data layout and access patterns