Re: Postgresql 9.0.2 explain analyze very slow (10x), compared to actual query time

From: Achilleas Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: Re: Postgresql 9.0.2 explain analyze very slow (10x), compared to actual query time
Date: 2011-01-13 10:35:12
Message-ID: 201101131235.13107.achill@matrix.gatewaynet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Στις Wednesday 12 January 2011 19:17:28 ο/η Mark Felder έγραψε:
> On Wed, 12 Jan 2011 10:45:20 -0600, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> >
> > The short of it is that cheap motherboards tend to provide cheap clock
> > hardware that takes about a microsecond to read.
>
> I'm not sure how gettimeofday() works, but is there a slight chance this
> could be alleviated by choosing a different kern.timecounter.hardware
> option?
>
> kern.timecounter.choice: TSC(800) HPET(900) ACPI-fast(1000) i8254(0)
> dummy(-1000000)
> kern.timecounter.hardware: ACPI-fast
>
> Or does the kernel timer stuff have nothing to do with gettimeofday()?
Thanx,
Actually setting sysctl kern.timecounter.hardware=TSC
and making the program look like: (increased the loop from 1,000,000 to 100,000,000)

#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
int main(int argc,char** argv) {
struct timeval *tp=calloc(1,sizeof(struct timeval));
int runna;
double micros_total=0;
for (runna=0;runna<100000000;runna++) {
int rc=gettimeofday(tp,NULL);
long micros = tp->tv_sec * 1000000 + tp->tv_usec;
micros_total = micros_total + (double) micros;
}
printf("micros_total=%f\n",micros_total);
}

I get in LINUX_PROD
time ./gettimeofday_test
micros_total=129491418242412709937152.000000

real 0m16.665s
user 0m16.621s
sys 0m0.000s

and in FBSD_TEST
time ./gettimeofday_test
micros_total=129491437864563859521536.000000

real 0m15.506s
user 0m0.517s
sys 0m1.161s

So, the FBSD_TEST case although still involves some kernel overhead, it is faster than LINUX_PROD
(but i am puzzled as to where those 15.5 secs come from since 1.16+
>
>
> Regards,
>
>
> Mark
>

--
Achilleas Mantzios

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Achilleas Mantzios 2011-01-13 12:13:21 Re: Postgresql 9.0.2 explain analyze very slow (10x), compared to actual query time
Previous Message Achilleas Mantzios 2011-01-13 10:17:52 Re: Postgresql 9.0.2 explain analyze very slow (10x), compared to actual query time