Unused indexes - PostgreSQL 9.2

From: Lucas Possamai <drum(dot)lucas(at)gmail(dot)com>
To: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Unused indexes - PostgreSQL 9.2
Date: 2016-05-10 20:40:38
Message-ID: CAE_gQfXY01jkAv9nze8sTQ+YHzrp4=_favpTtDmWhGkVTLhVKA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all,

I ran a query to search for unused indexes, and get some free space in my
DB:

SELECT
> --*,
> relid::regclass AS table,
> indexrelid::regclass AS index,
> --pg_size_pretty(pg_relation_size(indexrelid::regclass)) AS
> index_size,
> pg_relation_size(indexrelid::regclass) AS index_size,
> idx_tup_read,
> idx_tup_fetch,
> idx_scan
> FROM
> pg_stat_user_indexes
> JOIN pg_index USING (indexrelid)
> WHERE
> idx_scan = 0
> AND indisunique IS FALSE;

The query returns the columns:
idx_tup_read,
idx_tup_fetch,
idx_scan

*What I did was:*

1 - Run the query above
2 - select one index and drop it
3 - Found some slow queries... When I saw it, the query was using one of
the index I've dropped.
4 - Re-created the index
5 - Ran the query with explain analyze (The query was indeed hitting the
index)
6 - re-ran the first query above, and still.. the index wasn't being used
from those statistics
7 - ?

So, my problem is: the statistics are not running? What happened to the
statistics?

Do you guys know how can I update the stats?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Melvin Davidson 2016-05-10 21:02:14 Re: Unused indexes - PostgreSQL 9.2
Previous Message Bruce Momjian 2016-05-10 18:22:58 Re: Columnar store as default for PostgreSQL 10?