@cryptotaxi247 / netdata-1 / commits / 1456cac4a

go.d postgres: reset table/index bloat stats before querying (#17598)

Ilya Mashchenko committed May 6, 2024 at 12:55 UTC 1456cac4af77e6db2c063d6f842c049968098a88
1 file changed +17
src/go/collectors/go.d.plugin/modules/postgres/do_query_bloat.go
+17
@@ -22,6 +22,23 @@ func (p *Postgres) doQueryBloat() error {
22 func (p *Postgres) doDBQueryBloat(db *sql.DB) error {
23 q := queryBloat()
24
25 + for _, m := range p.mx.tables {
26 + if m.bloatSize != nil {
27 + m.bloatSize = newInt(0)
28 + }
29 + if m.bloatSizePerc != nil {
30 + m.bloatSizePerc = newInt(0)
31 + }
32 + }
33 + for _, m := range p.mx.indexes {
34 + if m.bloatSize != nil {
35 + m.bloatSize = newInt(0)
36 + }
37 + if m.bloatSizePerc != nil {
38 + m.bloatSizePerc = newInt(0)
39 + }
40 + }
41 +
42 var dbname, schema, table, iname string
43 var tableWasted, idxWasted int64
44 return p.doDBQuery(db, q, func(column, value string, rowEnd bool) {