I am a bit confused by the 'Date' data type on QuestDB. I was expecting this would store just a date, with no timestamp, but if I create a table with Date
data type it still accepts a timestamp.
Looking at the docs it says it uses 64 bits and:
Signed offset in milliseconds from Unix Epoch. While the date data type is available, we highly recommend applying the timestamp data type in its place. The only material advantage of date is a wider time range; timestamp however is adequate in virtually all cases. Date supports fewer functions and uses milliseconds instead of microseconds.
I can also see that timestamp uses 64 bits as well and:
Signed offset in microseconds from Unix Epoch.
So other than not being able to store data at microsecond resolution, which I don't need, what's the purpose of the data type? I am not sure what the claim The only material advantage of date is a wider time range
means
Talked on slack to a QuestDB developer and I was told for practical purposes I should use always timestamp. Since both take the same storage size, there is no upside in using Date
even if we don't need microsecond resolution.
The claim about wider range means that a date can represent times within a range of approximately ±2.9 million years from the Unix Epoch, due to the larger increments (milliseconds). The timestamp can represent "only" ±290,000 years from the Unix Epoch, as it needs to use storage for the microseconds.
Unless you are planning to record data ±290,000 years from the Unix Epoch you don’t need to worry about the Date type and you can stick with timestamps.