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

Re: timestamp(0) vs. timestamp

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Erwin Brandstetter <brsaweda(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: timestamp(0) vs. timestamp
Date: 2011-04-27 17:36:25
Message-ID: 5904.1303925785@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-general
Erwin Brandstetter <brsaweda(at)gmail(dot)com> writes:
> 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)?

There's no advantage to the system from knowing that, but consider that
having timestamp_in force the values to be nonfractional is likely to be
faster than having logic in a trigger to do it.

			regards, tom lane

In response to

Responses

pgsql-general by date

Next:From: Andy ColsonDate: 2011-04-27 17:40:08
Subject: Re: Needs Suggestion
Previous:From: Merlin MoncureDate: 2011-04-27 17:06:01
Subject: Re: Best way to construct PostgreSQL ArrayType (_int4) from C int array

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