Storing dates in MongoDB

I had quite a few questions about the best storage ideas for dates in MongoDB. most answers come down to using JavaScript Date objects.

I have one more question: what is the most efficient way to store dates?

I work in a collection of about 5 million records and perform about 500 reads per minute in it, requesting $ gt or $ lt records the current timestamp. How are indexes built around the original JavaScript Date object? Are they more efficient by keeping the whole timestamp?

+4
source share
1 answer

Dates are stored as 64-bit integers in MongoDB.

See BSON Specification http://bsonspec.org/#/specification

+2
source

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


All Articles