Setting a field as index: true should also consider creating a compound index on createdAt #6450
finkinfridom
started this conversation in
Feature Requests & Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
We are using the REST APIs to import a lot of data: the more the data, the slower the API.
We started adding
index: true
(on the properties we used for filtering) but performances didn't change.Profiling the database we noticed most of the commands coming from the APIs:
find
statement with our filtersort
operation oncreatedAt
the
sort
operation (I think it's coming from the payload's core code) caused the index to be partially used.As per the documentation, we accessed
payload.db[collectionSlug].schema.index()
method to apply our custom indexes:This improved performances at API level and produced benefits on database side.
Shouldn't this approach be part of the payload's core? I mean, adding both the field index and the field+createdAt field index?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions