Re: [PERFORM] Help with tuning this query (with

John A Meinel <[email protected]>
Newsgroups gmane.comp.db.postgresql.devel.win32,gmane.comp.db.postgresql.performance
Message-ID <[email protected]>
Tom Lane wrote:

>"Magnus Hagander" <[email protected]> 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;
}
signature.asc (application/pgp-signature, 256 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCLIF6JdeBCYSNAAMRAgvEAJ4rg9GJNkX0j+ViiQ6nGE8MIS1GVwCdFKQ3
iOPu9Lp51/cPaHoZ4TJ7LoQ=
=RE9x
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.