I have a table in MongoDB having UUID field named artwork_id, and i need to create index on that field, which type of index will be better?
db.artwork_images.createIndex( { artwork_id: "text" } )
OR
db.artwork_images.createIndex( { artwork_id: 1 } )
[Image of UUID field here][1] [1]: https://i.stack.imgur.com/XvHsN.png
Text indexes are meant to match words inside a field without having to access to the document. In this case you have an UUID field, so you are going to match the whole string every time.
Regular indexes are useful for matching the entire value of a field. If you only want to match on a specific word in a field with a lot of text, then use a text index.
I recommend to have a look to this post Performance best practices indexing