What is the fastest way to truncate timestamps to 5 minutes in Postgres?

后端 未结 3 445
故里飘歌
故里飘歌 2020-12-07 17:40

Postgres can round (truncate) timestamps using the date_trunc function, like this:

date_trunc(\'hour\', val)
date_trunc(\'minute\', val)

I\

3条回答
  •  情书的邮戳
    2020-12-07 18:02

    I don't think there is any quicker method.

    And I don't think you should be worried about the performance of the expression.

    Everything else that is involved in executing your (SELECT, UPDATE, ...) statement is most probably a lot more expensive (e.g. the I/O to retrieve rows) than that date/time calculation.

提交回复
热议问题