Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 5D2E1B5DBE3 for ; Thu, 12 May 2011 15:18:15 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 39804-02 for ; Thu, 12 May 2011 18:18:08 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.gransy.com (mail.gransy.com [82.208.29.194]) by mail.postgresql.org (Postfix) with ESMTP id D5A67B5D8B2 for ; Thu, 12 May 2011 15:18:07 -0300 (ADT) Received: from [192.168.1.221] (ip-94-112-0-189.net.upcbroadband.cz [94.112.0.189]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.gransy.com (Postfix) with ESMTPSA id 9600B4A21D9 for ; Thu, 12 May 2011 20:18:05 +0200 (CEST) Message-ID: <4DCC245D.9030001@fuzzy.cz> Date: Thu, 12 May 2011 20:18:05 +0200 From: Tomas Vondra User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101219 Lightning/1.0b3pre Thunderbird/3.1.7 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: since when has pg_stat_user_indexes.idx_scan been counting? References: In-Reply-To: X-Enigmail-Version: 1.1.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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 X-Spam-Level: X-Archive-Number: 201105/180 X-Sequence-Number: 43689 Dne 12.5.2011 17:39, Willy-Bas Loos napsal(a): > Hi, > > We have some indexes that don't seem to be used at all. > I'd like to know since when they have not been used. > That is, the time when postgres started counting to reach the number > that is in pg_stat_user_indexes.idx_scan > > Is there a way to retrieve that from the database ? Well, not really :-( You could call pg_postmaster_start_time() to get the start time, but that has two major drawbacks (1) The stats may be actually collected for much longer, because restart does not reset them. (2) If someone called pg_stat_reset(), the stats are lost but the start time remains the same. So there really is no reliable way to do detect this. In 9.1 this is not true - there's a timestamp for each database (and global stats) to keep track of the last reset. regards Tomas