MongoDB Indexes

I am trying to convert a Rails application to use mongodb through mongoid. I have two questions regarding indexes. I think I know the answer, but I want to get confirmation from someone who has more experience with the Mongod.

Take a look at the following example, where I have one relational relationship between Usersand Posts.

user.rb

class User  
    has_many_related :posts  
end

post.rb

class Post  
    belongs_to_related :user  
end

Now, when I look at indexes created through the MongoHQ interface, I notice the following two:

  • Keyword: _id_
    Indexed field: _id
    Unique: <blank>
    Is the identifier unique? If so, then why is this not the only set. If not, how can I install this and do I need?

  • : user_id_1
    : user_id
    : false
    , ? , , _1 .

+3
3

, _id MongoDB . , UNIQUE .

+3

MongoDB .

_id

_id ** _id, MongoDB . _id.

_id , _id. _id. _id - ObjectID ()

** _id , getIndexes() : true mongo.

+2

_id MongoDB, BSON, 12- .

12- 4- , , 3- . .

: MongoDB: NoSQL ()

+1

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


All Articles