Reputation: 7106
If I don't need precision more than the number of seconds since the Unix epoch, is there one or more advantages of keeping a date at which a document has been created/inserted in addition to the _id
?
(Note that the _id
already includes a timestamp - i.e. number of seconds since the Unix epoch - representing the date/time at which the document has been inserted.)
Especially, will a query with a criteria on creation/insertion date will perform well when only using the _id
?
Upvotes: 0
Views: 40
Reputation: 2777
Eventhough it is enough. It makes the application less readable. And if you are going to query over the dates (like documents after a specific date.) then it will be slower since in mongodb , BSON matching used when it comes to querying.
Upvotes: 0
Reputation: 43235
If you just need to know unix time for the document, then _id would suffice. However it would not provide you rich querying that ISODate() can provide like querying for date ranges, or day of the month.
Upvotes: 1