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

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

From: John A Meinel <john(at)arbash-meinel(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Magnus Hagander <mha(at)sollentuna(dot)net>,Ken Egervari <ken(at)upfactor(dot)com>, pgsql-performance(at)postgresql(dot)org,pgsql-hackers-win32(at)postgresql(dot)org
Subject: Re: [PERFORM] Help with tuning this query (with
Date: 2005-03-07 16:29:46
Message-ID: 422C817A.8050009@arbash-meinel.com (view raw or flat)
Thread:
Lists: pgsql-hackers-win32pgsql-performance
Tom Lane wrote:

>"Magnus Hagander" <mha(at)sollentuna(dot)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;
}

In response to

Responses

pgsql-performance by date

Next:From: Tom LaneDate: 2005-03-07 16:38:51
Subject: Re: [PERFORM] Help with tuning this query (with explain analyze finally)
Previous:From: tsarevichDate: 2005-03-07 14:46:38
Subject: Tuning, configuration for 7.3.5 on a Sun E4500

pgsql-hackers-win32 by date

Next:From: Tom LaneDate: 2005-03-07 16:38:51
Subject: Re: [PERFORM] Help with tuning this query (with explain analyze finally)
Previous:From: Tom LaneDate: 2005-03-07 14:45:37
Subject: Re: [PERFORM] Help with tuning this query (with explain analyze finally)

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