Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Field indexes not being created

default discord avatar
devperson2 years ago
2

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: {
    description:
      'The unique identifier for this page. This will be used in the URL.',
    position: 'sidebar'
  },


Anyone got any insights to this?



Running


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

await members.syncIndexes()

creates the index

  • default discord avatar
    nikich2 years ago

    Hey,

    @932901256136114206

    ! Have you applied

    index: true

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

  • default discord avatar
    devperson2 years ago

    Ah yeah, good to know

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.