Skip to content

Commit 873ce99

Browse files
authored
Update docs/database/indexes.mdx
1 parent 9849d3d commit 873ce99

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

docs/database/indexes.mdx

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,28 +65,15 @@ export const MyCollection: CollectionConfig = {
6565
```
6666
## Localized fields and MongoDB indexes
6767

68-
<Banner type="info">
69-
**Note:** If you set <code>index: true</code> or <code>unique: true</code> on a field that is also
70-
<code>localized: true</code>, the database will create one index <strong>per locale path</strong>
71-
(for example, <code>slug.en</code>, <code>slug.da-dk</code>, ...). With many locales and several
72-
indexed fields, this can significantly increase the total number of indexes on a collection and may
73-
approach MongoDB’s per-collection index limit.
74-
</Banner>
75-
76-
<strong>Recommendations</strong>
77-
- Only index the specific locale paths you actually query by using the collection-level
78-
<code>indexes</code> option instead of setting <code>index: true</code> directly on a localized field.
79-
- Prefer narrowly scoped or compound indexes tailored to your queries.
68+
When you set `index: true` or `unique: true` on a localized field, MongoDB creates one index **per locale path** (e.g., `slug.en`, `slug.da-dk`, etc.). With many locales and indexed fields, this can quickly approach MongoDB's per-collection index limit.
8069

81-
<strong>Example: index a specific locale only</strong>
70+
If you know you'll query specifically by a locale, index only those locale paths using the collection-level `indexes` option instead of setting `index: true` on the localized field. This approach gives you more control and helps avoid unnecessary indexes.
8271

8372
```ts
8473
import type { CollectionConfig } from 'payload'
8574

8675
export const Pages: CollectionConfig = {
87-
fields: [
88-
{ name: 'slug', type: 'text', localized: true },
89-
],
76+
fields: [{ name: 'slug', type: 'text', localized: true }],
9077
indexes: [
9178
// Index English slug only (rather than all locales)
9279
{ fields: ['slug.en'] },

0 commit comments

Comments
 (0)