[DOCS-1298] Comment on: "manual/core/object-id.txt" Created: 25/Mar/13  Updated: 01/Apr/13  Resolved: 29/Mar/13

Status: Closed
Project: Documentation
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Blocker - P1
Reporter: Tilo S Assignee: Sam Kleinman (Inactive)
Resolution: Done Votes: 0
Labels: collector-298ba4e7
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

MongoDB 2.2

Location: http://docs.mongodb.org/manual/core/object-id/
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.26.17 (KHTML, like Gecko) Version/6.0.2 Safari/536.26.17
Referrer: http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CDYQFjAA&url=http%3A%2F%2Fdocs.mongodb.org%2Fmanual%2Fcore%2Fobject-id&ei=lpBQUfPPK8mziwKhuICICw&usg=AFQjCNH2qKto2l0j7fwuzWX2-f9J-i54qg&sig2=WCgs5Jli4zcxuA0WD8xBMg&bvm=bv.44158598,d.cGE
Screen Resolution: 1680 x 1050
repo: docs
source: core/object-id


Participants:
Days since reply: 10 years, 46 weeks, 2 days ago

 Description   

the documentation says:

Sorting on an _id field that stores ObjectId values is equivalent to sorting by creation time.

that does not seem to be the case, e.g. I have the following keys (in insertion order), when sorted by _id, they do not reflect insertion time:

_id insertion_time.to_i
"50999c8c91e3783e0e000001", 1352244364
"50999c8c91e3783e0e000002", 1352244364
"50999c8c91e3783df4000001", 1352244364 <-- _id not larger than pervious _id
"50999c8c91e3783e08000001", 1352244364
"50999c8c91e3783e08000002", 1352244364
"50999c8c91e3783e50000001", 1352244364
"50999c8d91e3783e0e000003", 1352244365
"50999c8d91e3783e0e000004", 1352244365
"50999c8d91e3783e21000001", 1352244365
"50999c8d91e3783e21000002", 1352244365

Reporter: Tilo S



 Comments   
Comment by auto [ 01/Apr/13 ]

Author:

{u'date': u'2013-04-01T15:14:47Z', u'name': u'Sam Kleinman', u'email': u'samk@10gen.com'}

Message: DOCS-1298: objectid sorting
Branch: master
https://github.com/mongodb/docs/commit/d93be82c82e1d26d250ae76ba852154fce2171b9

Comment by auto [ 01/Apr/13 ]

Author:

{u'date': u'2013-04-01T15:14:47Z', u'name': u'Sam Kleinman', u'email': u'samk@10gen.com'}

Message: DOCS-1298: objectid sorting

Conflicts:
source/core/object-id.txt
Branch: v2.2
https://github.com/mongodb/docs/commit/19aa6b26bde114279db6a897d100c6a57c906fcd

Comment by Tilo S [ 29/Mar/13 ]

Hi Sam,

I see the jira ticket is now closed, but that sentence is still in the documentation:

Sorting on an _id field that stores ObjectId values is equivalent to sorting by creation time.

this is factually incorrect, and needs to be clarified

regards
Tilo

Comment by auto [ 29/Mar/13 ]

Author:

{u'date': u'2013-03-28T14:18:20Z', u'name': u'Sam Kleinman', u'email': u'samk@10gen.com'}

Message: DOCS-1298 objectid timestamps have second-level resolution
Branch: master
https://github.com/mongodb/docs/commit/05cde03d756fefbf1deb54152d3d1be89b8a5d82

Comment by Tilo S [ 28/Mar/13 ]

I just realized that what I'm seeing might be due to the fact that the finest granularity of MongoDB's _id's might be just 1 second – can you verify this? – if that's the case, there should be at least a big disclaimer in the documentation.

This was mentioned in this talk: http://www.10gen.com/presentations/mongosv-2011/mongodb-as-a-message-queue

If that's true, this means that if you add lots of records within the same second, it can happen that when you look at the records in insertion order, that the _id is not continuously growing - e.g. _id is not always sorted by real creation time

If this is true, one should use an inserted_at timestamp for sorting, rather than the _id

Comment by Kay Kim (Inactive) [ 27/Mar/13 ]

Hi Tilo – Updated. Regards. Kay

Comment by Tilo S [ 27/Mar/13 ]

Kay, can you please modify JIRA for this Bug, so it correctly associates this bug with my account, instead of showing my full name and email address? thank you! Email addresses should never be visible when not logged in

Comment by Tilo S [ 27/Mar/13 ]

this happened on a non-sharded replicaset

Generated at Thu Feb 08 07:40:42 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.