Field indexes not being created

default discord avatar
3 months ago

Bit of a weird one -- been debugging some performance issues with Payload and have noticed some of the indexes we defined on a field haven't been working

This doesn't seem to be happening consistently across our application, for example this field did not have an index:

  name: 'externalId',
  label: 'External ID',
  type: 'text',
  access: {
    read: adminOnly,
    update: () => false
  index: true,
  unique: true

Other similar fields have had an index though, for example this slug index:

  name: 'slug',
  type: 'text',
  label: 'Slug',
  index: true,
  unique: true,
  admin: {
      'The unique identifier for this page. This will be used in the URL.',
    position: 'sidebar'

Anyone got any insights to this?


const members = payload.collections['members'].Model

await members.syncIndexes()

creates the index

  • default discord avatar
    3 months ago

    Hey, @devperson! Have you applied

    index: true

    after collection items was created? If yes, this might be the issue, AFAIK.

  • default discord avatar
    3 months ago

    Ah yeah, good to know

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!


Connect with the Payload Community on Discord



Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.