Ad Widget

Collapse

How get "select" statement for PostgreSQL "Get bloating tables" metric

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • darko11z
    Junior Member
    • Jun 2022
    • 18

    #1

    How get "select" statement for PostgreSQL "Get bloating tables" metric

    Hi,
    on Zabbix 6.0 in web browser I have created a graph for PostgreSQL database with default metric Get bloating tables.
    This metric is showing high number and I would like to know how is this metric calculated?

    Is there some SELECT statement that is executed to PostgreSQL database? If yes, can someone copy it here or point me to the source where this select is stored.
    Regards
  • Answer selected by darko11z at 12-12-2023, 16:00.
    darko11z
    Junior Member
    • Jun 2022
    • 18

    PROBLEM SOLVED.

    It looks like I have found the SELECT statements. They are at:
    https://git.zabbix.com/projects/AP/r...Frelease%2F6.0

    For Get bloating table metric there is SQL (key name: pgsql.db.bloating_tables):
    HTML Code:
    SELECT count(*)
    FROM pg_catalog.pg_stat_all_tables
    WHERE (n_dead_tup/(n_live_tup+n_dead_tup)::float8) > 0.2
    AND (n_live_tup+n_dead_tup) > 50;
    ​
    Replacing "count(*)" for "*" and manually execute the SQL on database and table names are displayed.
    I have manually vacuumed them and now my metric fall to 0.

    Excellent. Problem solved.
    Last edited by darko11z; 12-12-2023, 15:59.

    Comment

    • darko11z
      Junior Member
      • Jun 2022
      • 18

      #2
      PROBLEM SOLVED.

      It looks like I have found the SELECT statements. They are at:
      https://git.zabbix.com/projects/AP/r...Frelease%2F6.0

      For Get bloating table metric there is SQL (key name: pgsql.db.bloating_tables):
      HTML Code:
      SELECT count(*)
      FROM pg_catalog.pg_stat_all_tables
      WHERE (n_dead_tup/(n_live_tup+n_dead_tup)::float8) > 0.2
      AND (n_live_tup+n_dead_tup) > 50;
      ​
      Replacing "count(*)" for "*" and manually execute the SQL on database and table names are displayed.
      I have manually vacuumed them and now my metric fall to 0.

      Excellent. Problem solved.
      Last edited by darko11z; 12-12-2023, 15:59.

      Comment

      Working...