Thread: Is there a way to check which indexes are being used for a table

Is there a way to check which indexes are being used for a table

From
Dragan Matic
Date:
We have a 50 GB database (currently using postgresql 8.1.1) with a few
hundred tables. There are a few larger (2-5 million rows) tables with
multiple indexes on them, some being unique, some not. Now, I am pretty
sure some of the indexes are pretty useless and are never used but is
there a way to see which indexes have been used on a table (and how many
times) and which haven't? Statistics is turned on for a database, I can
see number of sequential scans and index scans for instance, but I would
like to know which indexes have been used and how many times.

Tnx in advance

Dragan Matic


Re: Is there a way to check which indexes are being used

From
Ragnar
Date:
On fim, 2006-02-23 at 14:15 +0100, Dragan Matic wrote:
> We have a 50 GB database (currently using postgresql 8.1.1) with a few
> hundred tables. There are a few larger (2-5 million rows) tables with
> multiple indexes on them, some being unique, some not. Now, I am pretty
> sure some of the indexes are pretty useless and are never used but is
> there a way to see which indexes have been used on a table (and how many
> times) and which haven't? Statistics is turned on for a database, I can
> see number of sequential scans and index scans for instance, but I would
> like to know which indexes have been used and how many times.

select * from pg_stat_user_indexes ;


> Tnx in advance
>
> Dragan Matic
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>


Re: Is there a way to check which indexes are being used

From
Vivek Khera
Date:
On Feb 23, 2006, at 8:47 AM, Ragnar wrote:

> select * from pg_stat_user_indexes ;

which level of stats do I need to enable this? block level or row
level or both?

thanks.


Re: Is there a way to check which indexes are being used

From
"Jim C. Nasby"
Date:
On Thu, Feb 23, 2006 at 10:44:38AM -0500, Vivek Khera wrote:
>
> On Feb 23, 2006, at 8:47 AM, Ragnar wrote:
>
> >select * from pg_stat_user_indexes ;
>
> which level of stats do I need to enable this? block level or row
> level or both?

Either-or, AFAIK. Block level will present less load on the system.
--
Jim C. Nasby, Sr. Engineering Consultant      jnasby@pervasive.com
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461