From: | Jeff Janes <jeff(dot)janes(at)gmail(dot)com> |
---|---|
To: | Oleg Serov <serovov(at)gmail(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Is there any way to measure disk activity for each query? |
Date: | 2015-06-18 23:07:27 |
Message-ID: | CAMkU=1w1S5K5D1QjqByv1yOTS4KcykvGYyXDifacQDUcRGQs9w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, Jun 18, 2015 at 3:05 PM, Oleg Serov <serovov(at)gmail(dot)com> wrote:
> Hello!
>
> I'm wondering, if there any way to measure how much disk-io were generated
> by a query?
>
For an individual query execution, you can explain it with
explain (analyze, buffers) select .....
It will report on the pages hit in the buffer cache versus the pages read.
However, for pages which were hit in the OS filesystem cache, those will be
reported as if they were read from disk. There is no way (that I know of)
to distinguish at the statement level true disk io from OS caching. The
best way may be to turn track_io_timing on, then you can see how much time
it spent waiting on pages. If not much time was spent, then it must be
coming from the OS cache.
If you enable pg_stat_statements extension, you can get the same data
summed over all natural calls of the same query string. 'Natural' meaning
executions from applications, not just queries manually decorated with
'explain (analyze,buffers)'. This too is best used in conjunction with
track_io_timing.
I've been thinking about making individual statements which
exceed log_min_duration_statement log their track_io_timing numbers and
their rusage numbers into the server log, rather than just their wall-time
durations as it does now. I'm not sure how that idea is going to work out
yet, though. Anyway, it wouldn't be until version 9.6 at minimum.
Also, for temp file, see log_temp_files config parameter.
Cheers,
Jeff
From | Date | Subject | |
---|---|---|---|
Next Message | 夏高 | 2015-06-18 23:29:19 | Re: Test for char errors |
Previous Message | Oleg Serov | 2015-06-18 22:05:22 | Is there any way to measure disk activity for each query? |