pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Greg Smith <greg@2ndquadrant.com>
To: Tomas Vondra <tv@fuzzy.cz>
Cc: pgsql-performance@postgresql.org
Subject: Re: [ADMIN] since when has pg_stat_user_indexes.idx_scan been counting?
Date: Thu, 12 May 2011 22:26:03 -0400
Message-ID: <4DCC96BB.1030609@2ndquadrant.com> (raw)
In-Reply-To: <4DCC4718.8000409@fuzzy.cz>
References: <BANLkTikhNLPhCjE819=RFG-+CB6UV4GbUA@mail.gmail.com>
	<BANLkTimeo-P+=fxKzui1Md2Siq_YJ7ASug@mail.gmail.com>
	<BANLkTinTsg18Wk9+JPrpfOXCkn-W0D2TNw@mail.gmail.com>
	<4DCC4718.8000409@fuzzy.cz>

Tomas Vondra wrote:
> Stats about access to the data (index/seq scans, cache hit ratio etc.)
> are stored in pg_stat_* and pg_statio_* catalogs, and are updated after
> running each query. AFAIK it's not a synchronous process, but when a
> backend finishes a query, it sends the stats to the postmaster (and
> postmaster updates the catalogs).
>   

Description in the docs goes over this in a little more detail 
http://www.postgresql.org/docs/current/static/monitoring-stats.html :

"The statistics collector communicates with the backends needing 
information (including autovacuum) through temporary files. These files 
are stored in the pg_stat_tmp subdirectory...When using the statistics 
to monitor current activity, it is important to realize that the 
information does not update instantaneously. Each individual server 
process transmits new statistical counts to the collector just before 
going idle; so a query or transaction still in progress does not affect 
the displayed totals. Also, the collector itself emits a new report at 
most once per PGSTAT_STAT_INTERVAL milliseconds (500 unless altered 
while building the server). So the displayed information lags behind 
actual activity. However, current-query information collected by 
track_activities is always up-to-date."

It's not synchronous at all.  The clients create a temporary file for 
the statistics collector and move on.  The actual statistics don't get 
updated until the statistics collector decides enough time has passed to 
bother, which defaults to at most every 500ms.

-- 
Greg Smith   2ndQuadrant US    greg@2ndQuadrant.com   Baltimore, MD
PostgreSQL Training, Services, and 24x7 Support  www.2ndQuadrant.us
"PostgreSQL 9.0 High Performance": http://www.2ndQuadrant.com/books




view thread (10+ messages)  latest in thread

Message-ID: <4DCC96BB.1030609@2ndquadrant.com>
Permalink:  ../4DCC96BB.1030609@2ndquadrant.com/
Also on:    postgresql.org/message-id/4DCC96BB.1030609@2ndquadrant.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: greg@2ndquadrant.com, tv@fuzzy.cz
  Subject: Re: [ADMIN] since when has pg_stat_user_indexes.idx_scan been counting?
  In-Reply-To: <4DCC96BB.1030609@2ndquadrant.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox