Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 15D209FB33A for ; Mon, 2 Apr 2007 05:44:17 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 67780-04 for ; Mon, 2 Apr 2007 05:44:08 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from heaven.kostyrka.org (h1634.serverkompetenz.net [81.169.154.44]) by postgresql.org (Postfix) with ESMTP id 463EF9FA4E4 for ; Mon, 2 Apr 2007 05:44:11 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by heaven.kostyrka.org (Postfix) with ESMTP id B1CDA4FB8C; Mon, 2 Apr 2007 10:44:08 +0200 (CEST) Received: from heaven.kostyrka.org ([127.0.0.1]) by localhost (heaven.kostyrka.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 28689-01; Mon, 2 Apr 2007 10:44:08 +0200 (CEST) Received: from andi-lap (localhost [127.0.0.1]) by heaven.kostyrka.org (Postfix) with SMTP id 5FBBD4FB8A; Mon, 2 Apr 2007 10:44:07 +0200 (CEST) Received: by andi-lap (sSMTP sendmail emulation); Mon, 2 Apr 2007 09:45:21 +0200 Date: Mon, 2 Apr 2007 09:45:21 +0200 From: Andreas Kostyrka To: Denis Lishtovny Cc: pgsql-performance@postgresql.org Subject: Re: How to determine which indexes are not using or using seldom in database Message-ID: <20070402074519.GC1382@andi-lap.la.revver.com> References: <20070402081739.696D19FB609@postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070402081739.696D19FB609@postgresql.org> User-Agent: mutt-ng/devel-r804 (Debian) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/6 X-Sequence-Number: 23883 * Denis Lishtovny [070402 09:20]: > Hello All. > > I have a lot of tables and indexes in database. I must to determine which > indexes are not using or using seldon in databese . I enabled all posible > statistics in config but a can`t uderstand how to do this. > Thanks. > > p.s for example i need this to reduce database size for increase backup > and restore speed. Indexes are not backuped, and you can increase restore speed by temporarily dropping them. Current pg_dumps should be fine from this aspect. Discovering which tables are unused via the database suggests more of a software eng. problem IMHO. And it is bound to be unprecise and dangerous, tables might get read from: *) triggers. That means some tables might be only consulted if user X is doing something. Or we have full moon. Or the Chi of the DBA barked 3 times this day. *) during application startup only (easy to solve by forcing all clients to restart) *) during a cron job (daily, weekly, monthly, bi-monthly) *) only during human orginated processes. Not a good thing to decide to drop tables just because nothing has accessed them for half an hour. Or even a week. Worse, some tables might have relationsships that are missing in the database (foreign constraint forgotten, or some relationships that are hard to express with SQL constraints). OTOH, if you just try to get a feel what parts of the database is active, you can start by enabling SQL statement logging, and analyze some of that output. Andreas