Precision of time types
Precision of time types
От:
Wolfgang Keller <wolfgang.keller.privat@gmx.de>
Дата:
Hello, and yet another clueless newbie question: The precision of time types is specified as follows in the documentation: "For the time types, the allowed range of p is from 0 to 6 when eight-byte integer storage is used, or from 0 to 10 when floating-point storage is used." When/how is the internal storage method determined? Compile-time option? Database-initialisation time option? Other? Unfortunately, the schema I am trying to implement using PostgreSQL specifies 9 digits (nanosecond precision) for its custom datetime column (don't ask me why, I'M just a poor mech eng). So, do I need to use a numeric type for the seconds and define my own composite datetime column or can I use a properly parameterized built-in time type of PostgreSQL? TIA, Sincerely, Wolfgang Keller
Re: Precision of time types
От:
Michael Glaesemann <grzm@seespotcode.net>
Дата:
On Nov 13, 2007, at 6:45 , Wolfgang Keller wrote: > When/how is the internal storage method determined? > > Compile-time option? Yes, depending on the --enable-integer-datetimes flag. > So, do I need to use a numeric type for the seconds and define my > own composite datetime column or can I use a properly parameterized > built-in time type of PostgreSQL? Are you looking at timestamps or durations? If you're looking at timestamps, you could use timestamp(0) + an additional column to hold the number of nanoseconds. If durations (mis-named intervals in SQL), you could either store it as an interval(0) + an additional column for nanoseconds, or perhaps the total number of seconds in a numeric column. As you suggest, you could wrap the two columns into a single composite type. Michael Glaesemann grzm seespotcode net