2020-10-05 11:08:56 -04:00
---
2022-05-31 11:09:02 -04:00
stage: Data Stores
2020-10-05 11:08:56 -04:00
group: Database
2022-09-21 17:13:33 -04:00
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments
2020-10-05 11:08:56 -04:00
---
2020-05-22 05:08:09 -04:00
# Database guides
2020-06-23 11:08:41 -04:00
## Database Reviews
- If you're creating a database MR for review, check out our [Database review guidelines ](../database_review.md ).
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 ](database_reviewer_guidelines.md ).
2020-05-22 05:08:09 -04:00
## Tooling
2022-08-04 08:11:22 -04:00
- [Understanding EXPLAIN plans ](understanding_explain_plans.md )
2020-06-04 11:08:21 -04:00
- [explain.depesz.com ](https://explain.depesz.com/ ) or [explain.dalibo.com ](https://explain.dalibo.com/ ) for visualizing the output of `EXPLAIN`
2021-03-25 11:09:35 -04:00
- [pgFormatter ](https://sqlformat.darold.net/ ) a PostgreSQL SQL syntax beautifier
2022-01-24 13:14:42 -05:00
- [db:check-migrations job ](dbcheck-migrations-job.md )
2020-05-22 05:08:09 -04:00
## Migrations
2022-08-08 05:12:15 -04:00
- [Different types of migrations ](../migration_style_guide.md#choose-an-appropriate-migration-type )
- [Create a regular migration ](../migration_style_guide.md#create-a-regular-schema-migration ), including creating new models
- [Post-deployment migrations guidelines ](post_deployment_migrations.md ) and [how to create one ](post_deployment_migrations.md#creating-migrations )
2022-10-04 23:09:43 -04:00
- [Legacy Background migrations guidelines ](background_migrations.md )
2022-08-08 05:12:15 -04:00
- [Batched background migrations guidelines ](batched_background_migrations.md )
- [Deleting migrations ](deleting_migrations.md )
- [Running database migrations ](database_debugging.md#migration-wrangling )
2022-04-13 14:08:33 -04:00
- [Migrations for multiple databases ](migrations_for_multiple_databases.md )
2022-04-08 08:08:48 -04:00
- [Avoiding downtime in migrations ](avoiding_downtime_in_migrations.md )
2022-08-08 05:12:15 -04:00
- [When and how to write Rails migrations tests ](../testing_guide/testing_migrations_guide.md )
2020-05-22 05:08:09 -04:00
- [Migrations style guide ](../migration_style_guide.md ) for creating safe SQL migrations
- [Testing Rails migrations ](../testing_guide/testing_migrations_guide.md ) guide
2022-04-08 08:08:48 -04:00
- [Post deployment migrations ](post_deployment_migrations.md )
2022-08-04 08:11:22 -04:00
- [Swapping tables ](swapping_tables.md )
2022-04-08 08:08:48 -04:00
- [Deleting migrations ](deleting_migrations.md )
2022-08-08 05:12:15 -04:00
- [SQL guidelines ](../sql.md ) for working with SQL queries
2020-10-02 08:09:03 -04:00
- [Partitioning tables ](table_partitioning.md )
2020-05-22 05:08:09 -04:00
## Debugging
2022-08-08 05:12:15 -04:00
- [Resetting the database ](database_debugging.md#delete-everything-and-start-over )
- [Accessing the database ](database_debugging.md#manually-access-the-database )
- [Troubleshooting and debugging the database ](database_debugging.md )
2022-08-04 14:09:24 -04:00
- Tracing the source of an SQL query using query comments with [Marginalia ](database_query_comments.md )
2020-05-22 05:08:09 -04:00
- Tracing the source of an SQL query in Rails console using [Verbose Query Logs ](https://guides.rubyonrails.org/debugging_rails_applications.html#verbose-query-logs )
## Best practices
2022-08-04 14:09:24 -04:00
- [Adding database indexes ](adding_database_indexes.md )
2022-08-04 17:08:44 -04:00
- [Foreign keys & associations ](foreign_keys.md )
2020-05-22 05:08:09 -04:00
- [Adding a foreign key constraint to an existing column ](add_foreign_key_to_existing_column.md )
2020-06-05 08:08:24 -04:00
- [`NOT NULL` constraints ](not_null_constraints.md )
2020-05-22 05:08:09 -04:00
- [Strings and the Text data type ](strings_and_the_text_data_type.md )
2022-08-04 14:09:24 -04:00
- [Single table inheritance ](single_table_inheritance.md )
2022-08-04 08:11:22 -04:00
- [Polymorphic associations ](polymorphic_associations.md )
2022-08-05 14:08:56 -04:00
- [Serializing data ](serializing_data.md )
- [Hash indexes ](hash_indexes.md )
- [Storing SHA1 hashes as binary ](sha1_as_binary.md )
2022-08-05 11:12:12 -04:00
- [Iterating tables in batches ](iterating_tables_in_batches.md )
2022-08-04 17:08:44 -04:00
- [Insert into tables in batches ](insert_into_tables_in_batches.md )
2022-08-04 08:11:22 -04:00
- [Ordering table columns ](ordering_table_columns.md )
2022-08-05 14:08:56 -04:00
- [Verifying database capabilities ](verifying_database_capabilities.md )
2022-08-05 11:12:12 -04:00
- [Query Count Limits ](query_count_limits.md )
- [Creating enums ](creating_enums.md )
2020-10-07 11:08:40 -04:00
- [Client-side connection-pool ](client_side_connection_pool.md )
2020-11-08 22:09:03 -05:00
- [Updating multiple values ](setting_multiple_values.md )
2020-11-16 16:09:02 -05:00
- [Constraints naming conventions ](constraint_naming_convention.md )
2022-08-05 17:09:12 -04:00
- [Query performance guidelines ](query_performance.md )
2021-05-07 08:10:27 -04:00
- [Pagination guidelines ](pagination_guidelines.md )
- [Pagination performance guidelines ](pagination_performance_guidelines.md )
2021-09-14 08:10:35 -04:00
- [Efficient `IN` operator queries ](efficient_in_operator_queries.md )
2022-04-01 17:09:24 -04:00
- [Data layout and access patterns ](layout_and_access_patterns.md )
2020-05-22 05:08:09 -04:00
## Case studies
2022-08-04 17:08:44 -04:00
- [Database case study: Filtering by label ](filtering_by_label.md )
- [Database case study: Namespaces storage statistics ](namespaces_storage_statistics.md )
2020-11-16 13:09:15 -05:00
## Miscellaneous
- [Maintenance operations ](maintenance_operations.md )
2021-02-24 16:11:16 -05:00
- [Update multiple database objects ](setting_multiple_values.md )