Обсуждение: Is there a way to know write statistics on an individual index

Поиск
Список
Период
Сортировка

Is there a way to know write statistics on an individual index

От
higherone
Дата:
Hi,

I know there's a pg_stats_user_indexes that gives statistics about the index scans/fetches, but I don't find any information about how many writes(insert/update/delete) happen on this individual index.
Is there some tool that could achieve this?

Thanks,
Alun

Re: Is there a way to know write statistics on an individual index

От
David Rowley
Дата:
On Thu, 8 Dec 2022 at 19:59, higherone <higherone@gmail.com> wrote:
> I know there's a pg_stats_user_indexes that gives statistics about the index scans/fetches, but I don't find any
informationabout how many writes(insert/update/delete) happen on this individual index.
 
> Is there some tool that could achieve this?

Is this a partial index? If not, those should just increase at the
same rate that's mentioned in pg_stat_user_tables for the table that
the index belongs to.

David



Re: Is there a way to know write statistics on an individual index

От
Maciek Sakrejda
Дата:
On Thu, Dec 8, 2022 at 2:53 AM David Rowley <dgrowleyml@gmail.com> wrote:
>
> On Thu, 8 Dec 2022 at 19:59, higherone <higherone@gmail.com> wrote:
> > I know there's a pg_stats_user_indexes that gives statistics about the index scans/fetches, but I don't find any
informationabout how many writes(insert/update/delete) happen on this individual index.
 
> > Is there some tool that could achieve this?
>
> Is this a partial index? If not, those should just increase at the
> same rate that's mentioned in pg_stat_user_tables for the table that
> the index belongs to.

Well, not deletes, right? And HOT updates won't affect indexes either,
so they should be subtracted from n_tup_upd.



Re: Is there a way to know write statistics on an individual index

От
higherone
Дата:
It's not a partial index, but I believe the pg_stat_user_tables contains all the writes on the table, which not necessarily updates the individual index I'm interested in (e.g. when the updated column is not part of the index columns) .


On Fri, Dec 9, 2022 at 2:06 PM Maciek Sakrejda <m.sakrejda@gmail.com> wrote:
On Thu, Dec 8, 2022 at 2:53 AM David Rowley <dgrowleyml@gmail.com> wrote:
>
> On Thu, 8 Dec 2022 at 19:59, higherone <higherone@gmail.com> wrote:
> > I know there's a pg_stats_user_indexes that gives statistics about the index scans/fetches, but I don't find any information about how many writes(insert/update/delete) happen on this individual index.
> > Is there some tool that could achieve this?
>
> Is this a partial index? If not, those should just increase at the
> same rate that's mentioned in pg_stat_user_tables for the table that
> the index belongs to.

Well, not deletes, right? And HOT updates won't affect indexes either,
so they should be subtracted from n_tup_upd.