Indexes - explanations?

default discord avatar
plainnn
3 months ago
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
    Payload Team
    3 months ago

    This will be an interesting read for you:

    https://www.mongodb.com/docs/manual/indexes/
  • default discord avatar
    plainnn
    3 months ago

    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
    Payload Team
    3 months ago

    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
    plainnn
    3 months ago

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

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

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

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