From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jeff Frost <jeff@frostconsultingllc.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: pg_stat_user_indexes view clarification
Date: Mon, 30 Jan 2006 17:24:47 -0500
Message-ID: <24159.1138659887@sss.pgh.pa.us> (raw)
In-Reply-To: <Pine.LNX.4.64.0601301319520.14339@discord.dyndns.org>
References: <Pine.LNX.4.64.0601301319520.14339@discord.dyndns.org>
Jeff Frost <jeff@frostconsultingllc.com> writes:
> Can someone set me straight on whether the following statements are true in
> postgresql-8.1.x and if they aren't true, what queries might I need to run to
> find these answers?
> The following query shows all indexes which are not used.
> select schemaname,relname,indexrelname,idx_tup_read,idx_tup_fetch from
> pg_stat_user_indexes where idx_tup_read = 0;
It's probably more reliable to look at whether idx_scan is increasing,
as idx_tup_read wouldn't increment during a scan that found zero
matching rows.
> The following query shows all indexes which have differing values between
> idx_tup_read and idx_tup_fetch indicating indexes which likely need rebuilt
> via REINDEX:
> select schemaname,relname,indexrelname,idx_tup_read,idx_tup_fetch from
> pg_stat_user_indexes where idx_tup_read != idx_tup_fetch;
Uh, no, that does NOT imply a need for REINDEX. In particular, a bitmap
indexscan increments idx_tup_read but not idx_tup_fetch --- the heap
fetches are counted in the parent table's idx_tup_fetch counter instead.
(This is because, in the situation where we are ANDing or ORing multiple
indexes in a bitmap scan, assigning responsibility for a heap fetch to
any particular index is impractical and likely misleading anyway.)
I believe the details of the distinction between idx_tup_read and
idx_tup_fetch changed in 8.1, but I don't remember exactly how it
worked before.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: tgl@sss.pgh.pa.us, jeff@frostconsultingllc.com
Subject: Re: pg_stat_user_indexes view clarification
In-Reply-To: <24159.1138659887@sss.pgh.pa.us>
References: <Pine.LNX.4.64.0601301319520.14339@discord.dyndns.org> <24159.1138659887@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox