Add pg_stat_kind_info system view

Поиск
Список
Период
Сортировка
От Tristan Partin
Тема Add pg_stat_kind_info system view
Дата
Msg-id DI6OFGHJ1B69.25YVDEP3BABRH@partin.io
обсуждение
Ответы Re: Add pg_stat_kind_info system view
Список pgsql-hackers
Hey hackers,

In 7949d959458[0], we introduced pluggable cumulative statistics.
Extensions could now register their own custom statistics. However,
there was no way for an extension author to introspect their custom
statistics through SQL, and I don't believe there is currently a way to
introspect builtin statistics either.

Additionally, there was no way to know how much shared memory each
statistics kind was using. We could only know the total shared memory
used by the statistics subsystem.

    dbltap@postgres=# SELECT * FROM pg_shmem_allocations WHERE name = 'Shared Memory Stats';
            name         |    off    |  size  | allocated_size
    ---------------------+-----------+--------+----------------
     Shared Memory Stats | 153456640 | 321976 |         321976

In this patch, I have added a new system view: pg_stat_kind_info built
on a new function pg_stat_get_kind_info(). The view has the following
columns:

- id: id of the statistics kind
- name: name of the statistics kind
- count: number of entries for the statistics kind
- builtin: whether the statistics kind of builtin or not
- shared_size: shared memory size of each entry

    dbltap@postgres=# SELECT * FROM pg_stat_kind_info;
     id |          name           | count  | builtin | shared_size
    ----+-------------------------+--------+---------+-------------
      1 | database                | (null) | t       |         288
      2 | relation                | (null) | t       |         248
      3 | function                | (null) | t       |          56
      4 | replslot                | (null) | t       |         120
      5 | subscription            | (null) | t       |         120
      6 | backend                 | (null) | t       |        2952
      7 | archiver                |      1 | t       |           0
      8 | bgwriter                |      1 | t       |           0
      9 | checkpointer            |      1 | t       |           0
     10 | io                      |      1 | t       |           0
     11 | lock                    |      1 | t       |           0
     12 | slru                    |      1 | t       |           0
     13 | wal                     |      1 | t       |           0
     25 | test_custom_var_stats   |      0 | f       |          40
     26 | test_custom_fixed_stats |      1 | f       |          56
    (15 rows)

I am not sure that shared_size is a good column name, and I needed to
include pgstat_internal.h in pgstatfuncs.c to get everything working.
I'm also curious to hear if anyone thinks there is other valuable
information to expose.

[0]: https://github.com/postgres/postgres/commit/7949d9594582ab49dee221e1db1aa5401ace49d4

--
Tristan Partin
PostgreSQL Contributors Team
AWS (https://aws.amazon.com)



В списке pgsql-hackers по дате отправления: