Michail Nikolaev <michail.nikol...@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


Reply via email to