Re: CPU time for pg_stat_statement - Mailing list pgsql-hackers

From Tom Lane
Subject Re: CPU time for pg_stat_statement
Date
Msg-id 488810.1653079169@sss.pgh.pa.us
Whole thread Raw
In response to CPU time for pg_stat_statement  (Michail Nikolaev <michail.nikolaev@gmail.com>)
Responses Re: CPU time for pg_stat_statement
List pgsql-hackers
Michail Nikolaev <michail.nikolaev@gmail.com> writes:
> So, looks like clock_gettime is not so accurate to measure real CPU
> usage for some OLTP workloads. I suppose it is caused by the wall time
> vs CPU time difference (IO, thread switch, etc).

This is a pretty broad claim to make on the basis of one undocumented
test case on one unmentioned platform.

> But what do you think about adding cpu_time (by calling getrusage) to
> pg_stat_statements? Seems it could be very useful for CPU profiling.

On what grounds do you claim getrusage will be better?  One thing we
can be pretty certain of is that it will be slower, since it has to
return many more pieces of information.  And the API for it only allows
time info to be specified to microseconds, versus nanoseconds for
clock_gettime, so it's also going to be taking a precision hit.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: check for null value before looking up the hash function
Next
From: Thomas Munro
Date:
Subject: Re: CPU time for pg_stat_statement