pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
now() with microsecond granulity needed
6+ messages / 3 participants
[nested] [flat]

* now() with microsecond granulity needed
@ 2001-02-20 16:31  Radoslaw Stachowiak <radek@alter.pl>
  0 siblings, 1 reply; 6+ messages in thread

From: Radoslaw Stachowiak @ 2001-02-20 16:31 UTC (permalink / raw)
  To: pgsql-sql

Hello!

using now() to init TIMESTAMP fields I got resolution of one second. How
can I define DEFAULT in column (TIMESTAMP type) to get higher
time-resolution (TIMESTAMP supports microseconds).

Please CC the answer to me.

-- 
radoslaw.stachowiak.........................................http://alter.pl/



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: now() with microsecond granulity needed
@ 2001-02-20 16:57  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Radoslaw Stachowiak <radek@alter.pl>
  0 siblings, 1 reply; 6+ messages in thread

From: Tom Lane @ 2001-02-20 16:57 UTC (permalink / raw)
  To: Radoslaw Stachowiak <radek@alter.pl>; +Cc: pgsql-sql

Radoslaw Stachowiak <radek@alter.pl> writes:
> using now() to init TIMESTAMP fields I got resolution of one second. How
> can I define DEFAULT in column (TIMESTAMP type) to get higher
> time-resolution (TIMESTAMP supports microseconds).

You could make a variant of now() that relies on gettimeofday() instead
of time().  Note that you probably won't get microsecond precision in
any case...

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: now() with microsecond granulity needed
@ 2001-02-21 20:54  Radoslaw Stachowiak <radek@alter.pl>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 6+ messages in thread

From: Radoslaw Stachowiak @ 2001-02-21 20:54 UTC (permalink / raw)
  To: pgsql-sql

*** Tom Lane <tgl@sss.pgh.pa.us> [Tuesday, 20.February.2001, 11:57 -0500]:
> > using now() to init TIMESTAMP fields I got resolution of one second. How
> > can I define DEFAULT in column (TIMESTAMP type) to get higher
> > time-resolution (TIMESTAMP supports microseconds).
> 
> You could make a variant of now() that relies on gettimeofday() instead
> of time().  Note that you probably won't get microsecond precision in
> any case...

Do You mean changing sources and recompiling?
So there is no way of getting more accurate NOW time directly in SQL ?
/DEFAULT clause/ at this moment?

I just have now about 5..10 inserts per second, so in fact even ms would help
me.

-- 
radoslaw.stachowiak.........................................http://alter.pl/



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: now() with microsecond granulity needed
@ 2001-02-21 20:57  Daniel Wickstrom <danw@rtp.ericsson.se>
  parent: Radoslaw Stachowiak <radek@alter.pl>
  0 siblings, 1 reply; 6+ messages in thread

From: Daniel Wickstrom @ 2001-02-21 20:57 UTC (permalink / raw)
  To: pgsql-sql

>>>>> "Radoslaw" == Radoslaw Stachowiak <radek@alter.pl> writes:

    Radoslaw> *** Tom Lane <tgl@sss.pgh.pa.us> [Tuesday,
    Radoslaw> 20.February.2001, 11:57 -0500]:
    >> > using now() to init TIMESTAMP fields I got resolution of one
    >> second. How > can I define DEFAULT in column (TIMESTAMP type)
    >> to get higher > time-resolution (TIMESTAMP supports
    >> microseconds).
    >> 
    >> You could make a variant of now() that relies on gettimeofday()
    >> instead of time().  Note that you probably won't get
    >> microsecond precision in any case...

    Radoslaw> Do You mean changing sources and recompiling?  So there
    Radoslaw> is no way of getting more accurate NOW time directly in
    Radoslaw> SQL ?  /DEFAULT clause/ at this moment?

the timeofday function seems to work:

acspg=# select timeofday();
              timeofday              
-------------------------------------
 Wed Feb 21 15:56:43.150389 2001 EST
(1 row)

acspg=# 



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: now() with microsecond granulity needed
@ 2001-02-21 21:55  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Daniel Wickstrom <danw@rtp.ericsson.se>
  0 siblings, 1 reply; 6+ messages in thread

From: Tom Lane @ 2001-02-21 21:55 UTC (permalink / raw)
  To: Daniel Wickstrom <danw@rtp.ericsson.se>; +Cc: pgsql-sql

Daniel Wickstrom <danw@rtp.ericsson.se> writes:
> the timeofday function seems to work:

Hmm, exactly what I was thinking of, except that it returns a text
rather than a timestamp (a strange choice...).  It seems a little
buggy as well because the formatting of the microseconds part is
wrong --- will fix that, and document it.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: now() with microsecond granulity needed
@ 2001-02-22 09:12  Radoslaw Stachowiak <radek@alter.pl>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Radoslaw Stachowiak @ 2001-02-22 09:12 UTC (permalink / raw)
  To: pgsql-sql

*** Tom Lane <tgl@sss.pgh.pa.us> [Wednesday, 21.February.2001, 16:55 -0500]:
> Hmm, exactly what I was thinking of, except that it returns a text
> rather than a timestamp (a strange choice...).

But it's implicit casted to timestamp type so i think is good choice to
use in DEFAULT clause at this moment. Correct me if I'm wrong.

> It seems a little
> buggy as well because the formatting of the microseconds part is
> wrong --- will fix that, and document it.

In 7.1 version?

-- 
radoslaw.stachowiak.........................................http://alter.pl/



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2001-02-22 09:12 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-02-20 16:31 now() with microsecond granulity needed Radoslaw Stachowiak <radek@alter.pl>
2001-02-20 16:57 ` Tom Lane <tgl@sss.pgh.pa.us>
2001-02-21 20:54   ` Radoslaw Stachowiak <radek@alter.pl>
2001-02-21 20:57     ` Daniel Wickstrom <danw@rtp.ericsson.se>
2001-02-21 21:55       ` Tom Lane <tgl@sss.pgh.pa.us>
2001-02-22 09:12         ` Radoslaw Stachowiak <radek@alter.pl>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox