Multi Key Indexes

In chapter 2, lecture on multi key indexes - the instructor at 4:33 indicates that the schema with list of product names isn’t particularly a good one to use in production. Can someone please elaborate if I am missing some concept here.
Is the instructor implying that we shouldn’t create a multi key index on an array field which can grow in size or we shouldn’t have a growing array field or something else.

Thank you

Hi @Surajit_Barman,

If there is a products collection with the following document:

The instructor then created a compound multikey index which got created successfully because only stock field is an array.

Now if we try to insert a document where productName is an array but stock is not, the operation would be successful. However, this is not a good practice in production.

In case of Multi key indexes, the server creates index keys for each array element. So, we need to be careful as generating huge number of index keys would affect the performance of the queries as the index would no longer fit in RAM.

I hope it answers your question.

Please feel free to reach out if you have any additional questions.