pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: John A Meinel <john@arbash-meinel.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Magnus Hagander <mha@sollentuna.net>
Cc: Ken Egervari <ken@upfactor.com>
Cc: pgsql-performance@postgresql.org
Cc: pgsql-hackers-win32@postgresql.org
Subject: Re: [PERFORM] Help with tuning this query (with
Date: Mon, 07 Mar 2005 10:29:46 -0600
Message-ID: <422C817A.8050009@arbash-meinel.com> (raw)
In-Reply-To: <23086.1110206737@sss.pgh.pa.us>
References: <6BCB9D8A16AC4241919521715F4D8BCE476A60@algol.sollentuna.se>
	<23086.1110206737@sss.pgh.pa.us>

Tom Lane wrote:

>"Magnus Hagander" <mha@sollentuna.net> writes:
>
>
>>There is. I beleive QueryPerformanceCounter has sub-mirosecond
>>resolution.
>>
>>
>>Can we just replace gettimeofday() with a version that's basically:
>>
>>
>
>No, because it's also used for actual time-of-day calls.  It'd be
>necessary to hack executor/instrument.c in particular.
>
>			regards, tom lane
>
>
It seems that there are 2 possibilities. Leave gettimeofday as it is,
and then change code that calls it for deltas with a
"pg_get_high_res_delta_time()", which on most platforms is just
gettimeofday, but on win32 is a wrapper for QueryPerformanceCounter().

Or we modify the win32 gettimeofday call to something like:

gettimeofday(struct timeval *tv, struct timezone *tz)
{
  static int initialized = 0;
  static LARGE_INTEGER freq = {0};
  static LARGE_INTEGER base = {0};
  static struct time_t base_tm = {0};
  LARGE_INTEGER now = {0};
  int64_t delta_secs = 0;

  if(!initialized) {
    QueryPerformanceFrequency(&freq);
    base_tm = time(NULL); // This can be any moderately accurate time
function, maybe getlocaltime if it exists
    QueryPerformanceCounter(&base);
  }

  QueryPerformanceCounter(&now);
  delta_secs = now.QuadPart - base.QuadPart;
  tv->tv_sec = delta_secs / freq.QuadPart;
  delta_secs -= *tv.tv_sec * freq.QuadPart;
  tv->tv_usec = delta_secs * 1000000 / freq.QuadPart

  tv->tv_sec += base_tm;

   return 0;
}

Attachments:

  signature.asc (application/pgp-signature, 255B) download

view thread (16+ messages)  latest in thread

Message-ID: <422C817A.8050009@arbash-meinel.com>
Permalink:  ../422C817A.8050009@arbash-meinel.com/
Also on:    postgresql.org/message-id/422C817A.8050009@arbash-meinel.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: john@arbash-meinel.com, tgl@sss.pgh.pa.us, mha@sollentuna.net, ken@upfactor.com, pgsql-hackers-win32@postgresql.org
  Subject: Re: [PERFORM] Help with tuning this query (with
  In-Reply-To: <422C817A.8050009@arbash-meinel.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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