Indexes - explanations?

default discord avatar
plainnnlast year
5

Hi, I've seen indexes as an option for collections but i'm struggling to find much more on them. I assume they make data retrieval faster but would love some more details.



I did a search in here and found this -

https://github.com/payloadcms/payload/blob/master/test/fields/collections/Indexed/index.ts

but it doesn't give much explanation!

  • discord user avatar
    alessiogr
    last year

    This will be an interesting read for you:

    https://www.mongodb.com/docs/manual/indexes/
  • default discord avatar
    plainnnlast year

    Thank you



    So if I understand correctly, if I had a collection of posts (image, text, date, few boolean values) there isn't much point indexing them. Since we need the entire collection and don't query for single fields or values

  • discord user avatar
    alessiogr
    last year

    Unless you want to, for example, search or filter your collections by those boolean values for example. With indexes, that would be faster

  • default discord avatar
    plainnnlast year

    We just list them out, like a social media feed so I guess they aren't needed. Thanks for explaining 🙂

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

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