0

Just saw this question: Nanoseconds lost coming from MongoDB ISODate Object

Asking because, 3GHz processor can do max 9 instructions per nanosecond (sure not enough to store anything into mongodb) and memory speed is ten times slower anyway. I'm not sure how precise is the network time sync.

Wondering for what purpose is useful and usually used the nanosecond value in any (standard) programming language/system.

Community
  • 1
  • 1
novacik
  • 1,497
  • 1
  • 9
  • 19
  • 1
    Because using nanoseconds lets you [go up to "11"](http://www.youtube.com/watch?v=ll7rWiY5obI) ;) – paulsm4 Jul 04 '13 at 20:10
  • Very handy for making unique timestamps. – Lennart Regebro Jul 04 '13 at 20:15
  • 2
    Some people think that the higher precision equates to higher accuracy and is some way better. There's no use for nanosecond precision in standard computing. For many common applications even seconds is more precision than needed. –  Jul 04 '13 at 20:17
  • Resolution and accuracy are different concepts. Nanosecond resolution can have its uses; nanosecond accuracy from the system clock is not really attainable, but not all times come from the system clock. Sometimes microsecond resolution is not sufficient. – Jonathan Leffler Jul 07 '13 at 04:06
  • The significance is mostly that nanosecond resolution will usually be guaranteed to give you an unique value with each request, so the clock values can be used as identifiers or used to determine the order of events. (Though some clocks with only microsecond accuracy also guarantee uniqueness via extra bits tacked on the end.) – Hot Licks Jul 07 '13 at 04:18

1 Answers1

2

info ls mentions a --time-style=full-iso option, with this description:

List timestamps in full using ISO 8601 date, time, and time
zone format with nanosecond precision, e.g., `2002-03-30
23:45:56.477817180 -0700'.  This style is equivalent to
`+%Y-%m-%d %H:%M:%S.%N %z'.

This is useful because the time output includes all the
information that is available from the operating system.  For
example, this can help explain `make''s behavior, since GNU
`make' uses the full timestamp to determine whether a file is
out of date.

(Your mileage may vary.)


Edited to add: Also, RFC 4122, which defines UUIDs, gives several algorithms for generating them, including a few "time-based" algorithms. These all require 100ns resolution. Since it would not make sense to offer a "tenths-of-microseconds" field, this requires a "nanoseconds" field, even if meaningful 1ns resolution is not offered.

(And I feel compelled to point out that, in the question you link to, the asker is actually only storing up to milliseconds in MongoDB. The question asks about "nanoseconds" only because that is the field that stores sub-second resolution.)

ruakh
  • 175,680
  • 26
  • 273
  • 307
  • GREAT answer. I'm not really care about the "on hold" - this question is not opinion based but here is (as you show) an real need (and you gave a logical explanation) for nanoseconds. Thank you very much. – novacik Jul 08 '13 at 15:21