Answer the question
In order to leave comments, you need to log in
Do I understand indexing correctly?
I have id and day fields.
It is often used to search simply by id and search by id + day.
And, in fact, how do I need to create an index:
On id + day
On id and day separately
On id + day and again separately on id
And another question, day is the day of the week and can contain a number up to 6, and id is infinite number and it would be more correct to search first by day and then by id. Does Monga do this herself or do I need to first specify day in the code, that is:
{day: 3, id: 205580268} instead of {id: 205580268, day: 3}?
Answer the question
In order to leave comments, you need to log in
right
if there is not enough space, you can only id, or only id + only dey
the general principle of composite indexes is first long, then short
but you can check experimentally, 1-10k queries are enough
in general if you have so much fun - can make 7 collections and search depending on the day
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question