diff --git a/doc/development/database/batched_background_migrations.md b/doc/development/database/batched_background_migrations.md index 79a004988bd059930e2566684a6ffbe8de6c47d7..879e351696237ee8cd9ebe577f636814a34049af 100644 --- a/doc/development/database/batched_background_migrations.md +++ b/doc/development/database/batched_background_migrations.md @@ -370,10 +370,11 @@ end #### Using a composite or partial index to iterate a subset of the table When applying additional filters, it is important to ensure they are properly -covered by an index to optimize `EachBatch` performance. +[covered by an index](iterating_tables_in_batches.md#example-2-iteration-with-filters) +to optimize `EachBatch` performance. In the below examples we need an index on `(type, id)` or `id WHERE type IS NULL` to support the filters. See -[the `EachBatch` documentation for more information](iterating_tables_in_batches.md). +the [`EachBatch` documentation](iterating_tables_in_batches.md) for more information. If you have a suitable index and you want to iterate only a subset of the table you can apply a `where` clause before the `each_batch` like: