What are the performance costs associated with using a user id in Mongodb

I plan to use this NPM (shortid) package to create shorter identifiers, primarily for use in URLs, I want to use them because (at least for some collections).

What are the costs associated with using user identifiers? Will this affect search time, recording time, etc. Any significant way?

+4
source share
1 answer

These types of questions can quickly turn into a battle of opinions, rather than expressing an opinion, which, in my opinion, provides some pros and cons and allows you to decide what is best for this application will make more sense.

Assuming the "shortid" format will be saved as a string, I think that Abigail Watson's answer to a similar question on Google Groups sums up some of the larger items. Her answer is primarily aimed at Meteor apps, so some of her pro / minus are related to Meteor’s design decisions, but you can see how you should think about whether to use ObjectId“shortid”, an app-based solution .

All her answer:

ObjectId Pros

  • It has a built-in timestamp.
  • Mongo _id ;

ObjectId Cons

  • , - .
  • , ObjectId()
  • _id .

String Pros

  • _id .

String Cons

  • _ids
  • findAndModify() getNextSequence()

, , _id -. ObjectId , _id.

, ObjectIds . , . 10 20 , ObjectIds, 10x 100x . : - , , , R & D .

ObjectId , . . , , vs ObjectId ( - ) ,

, _id :

  • ?
  • ?
  • ?
  • ?

https://groups.google.com/d/msg/meteor-talk/f-ljBdZOwPk/oQYZQxCAKN8J

, , , " " URL-, URL-, URL-? ObjectId, , URL.

+3

Source: https://habr.com/ru/post/1598210/


All Articles