• Home
  • Jobs
  • coursesAndChallenges
  • Teachers
  • For business
  • Blog
  • ES/EN

0

10
Views
Indexing on MongoDB UUID field

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

11 days ago ·

Santiago Trujillo

1 answers
Answer question

0

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

11 days ago · Santiago Trujillo Report
Answer question
Remote jobs
Loading

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Startups
Legal
Terms and conditions Privacy policy
© 2022 PeakU Inc. All Rights Reserved.