How to use postgresql timestamp

1 is the original data in the table a numeric value or a formatted time string for Magi Postgresql timestamp?
2, if it is a formatted string, is his own sorting performance very poor?
3, if it is a numerical value, can you check it directly according to the numerical value?

Mar.13,2021

PostgreSQL provides the timestamp data type.

https://www.postgresql.org/do.

so don't store timestamp data as strings or integers, which will cost storage and query performance.


    The internal form of the
  1. TIMESTAMP type stored in the table is an 8-byte value, the expressible time range is 4713 BC to AD 294276 , and the smallest unit is subtle (microsecond)
  2. .
  3. because it's a numerical value, you don't have to worry about its sorting performance
  4. this problem is rather complicated

    Although the

    TIMESTAMP type is an 8-byte value, in order to mask the internal details to the user, its output is in the form of a string to output the timestamp (the format of the timestamp can be specified). Logically, the PG community does not want to expose internal values directly to the outside world.

    if we have to check it out as a numerical type, there seems to be no way to find its original 8-byte value, but we can "save the nation by curve" by converting the TIMESTAMP type to a Unix timestamp (since 00:00:00 GMT on January 1, 1970) followed by an integer:

    suppose you have the following table

      9.9. Date/Time Functions and Operators  

Menu