Skip to Main Content

MongoByte MongoDB Logo

Welcome to the new MongoDB Feedback Portal!

{Improvement: "Your idea"}
We’ve upgraded our system to better capture and act on your feedback.
Your feedback is meaningful and helps us build better products.

Status Submitted
Categories Database
Created by Guest
Created on Dec 16, 2022

Nanosecond timestamp support

I've put this under the time series category since that's where it's most applicable, but it's really a data model / BSON issue. The topic of higher resolution timestamps have been surfaced from time to time for at least a decade (https://jira.mongodb.org/browse/SERVER-1460), and usually prompts a response like "just use integers". With the addition of time series collections however, where the concept of time is integral to database functionality, I think it's time to reconsider adding a type with at least nanosecond precision timestamp support. Date's millisecond resolution is woefully inadequate for a number of relevant use cases, be it sensor data, financial data, log data, etc.
  • Attach files
  • Guest
    Mar 29, 2023
    As per the link below these are stored with millisecond precision https://www.mongodb.com/docs/manual/reference/bson-types/#std-label-document-bson-type-date BSON Date is a 64-bit integer that represents the number of milliseconds since the Unix epoch (Jan 1, 1970). This results in a representable date range of about 290 million years into the past and future. However for java.time.LocalDateTime , it is stored to nano second precision. https://docs.oracle.com/javase/8/docs/api/java/time/LocalDateTime.html Time is represented to nanosecond precision. For example, the value "2nd October 2007 at 13:45.30.123456789" can be stored in a LocalDateTime. Therefore we are not able to store the LocalDateTime as BSON Date type in Mongo and therefore we can not query using the LocalDateTime. The current workaround which we currently doing is to store them as String and deserialising them as LocalDateTime, however we can not query using the LocalDateTime.