Skip site navigation (1) Skip section navigation (2)

timestamp(0) vs. timestamp

From: Erwin Brandstetter <brsaweda(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: timestamp(0) vs. timestamp
Date: 2011-04-27 15:53:36
Message-ID: 80501703-39d6-45a6-a424-2ae0b21eb4a5@r6g2000vbz.googlegroups.com (view raw or flat)
Thread:
Lists: pgsql-general
Hi all!

This may seem unimportant, but I still would like to know.

I have columns for timestamps without fractional digits, so I could
define them as timestamp(0).
However, there is no way fractions could ever enter anyway, because
triggers and / or checks guarantee values without fractional seconds.

Is it advantageous to define the column as timestamp(0) or simply as
timestamp?
Does the query planner or any other part of the RDBMS profit from the
additional information in the definition?
Or do I just create an overhead of useless checks or conversions
(however small)?

In a scenario like that, what would be (however slightly) preferable:
CREATE TABLE x
(
   ...
   log_in timestamp(0) without time zone NOT NULL DEFAULT
(now())::timestamp without time zone
or
   log_in timestamp without time zone NOT NULL DEFAULT
(now())::timestamp(0) without time zone
or
   log_in timestamp(0) without time zone NOT NULL DEFAULT
(now())::timestamp(0) without time zone


TIA
Erwin Brandstetter


Responses

pgsql-general by date

Next:From: Thomas HaroldDate: 2011-04-27 15:55:33
Subject: Re: PHP and PostgreSQL 9.0, pg_connect fails to connect
Previous:From: Joel StevensonDate: 2011-04-27 15:52:49
Subject: Re: Column storage (EXTERNAL/EXTENDED) settings for bytea/text column

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group