Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 5305DB5D942 for ; Thu, 12 May 2011 23:26:18 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 43677-05 for ; Fri, 13 May 2011 02:26:11 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.17.10]) by mail.postgresql.org (Postfix) with ESMTP id ECF33B5D80A for ; Thu, 12 May 2011 23:26:10 -0300 (ADT) Received: from [192.168.1.3] (mail.highperformancepostgresql.com [71.179.240.8]) by mrelayeu.kundenserver.de (node=mreu4) with ESMTP (Nemesis) id 0Ll4qI-1PkolQ0XbC-00azia; Fri, 13 May 2011 04:26:10 +0200 Message-ID: <4DCC96BB.1030609@2ndquadrant.com> Date: Thu, 12 May 2011 22:26:03 -0400 From: Greg Smith User-Agent: Thunderbird 2.0.0.24 (X11/20100317) MIME-Version: 1.0 To: Tomas Vondra CC: pgsql-performance@postgresql.org Subject: Re: [ADMIN] since when has pg_stat_user_indexes.idx_scan been counting? References: <4DCC4718.8000409@fuzzy.cz> In-Reply-To: <4DCC4718.8000409@fuzzy.cz> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:Dy7r4k/OB2+jHv+MPFzMj0qVZ2H0yR24AiTRQRKR60P gnr8slamP2tYvfJDPpE+YC2DUo8eSuaRbCQKrQoC3oI6k5RzXf iliyWtBLicfAlIiT4/Yu1q7zfZJjKe7kWbLcljmINe40MEGzgu f3ZWYDSMYgYSZFrFDXfIIKKqf6VWZmgdcpiosDBeICzlt+ykAe poVCzvi9AqHMW7FnLzJv4Im7mZqElDZgt1vNI+6aw8= X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201105/198 X-Sequence-Number: 43707 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