Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #66 from ContaAzul/approx
Browse files Browse the repository at this point in the history
Use pgstattuple_approx
  • Loading branch information
brunomanzo authored Apr 20, 2020
2 parents 4c8e831 + 583ad10 commit 102860c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions gauges/deadtuples.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (g *Gauges) DeadTuples() *prometheus.GaugeVec {
for _, table := range tables {
var pct []float64
if err := g.queryWithTimeout(
"SELECT dead_tuple_percent FROM pgstattuple($1)",
"SELECT dead_tuple_percent FROM pgstattuple_approx($1)",
&pct,
[]interface{}{table.Name},
1*time.Minute,
Expand All @@ -57,8 +57,8 @@ func (g *Gauges) DeadTuples() *prometheus.GaugeVec {
}

func (g *Gauges) hasPermissionToExecutePgStatTuple() bool {
if _, err := g.db.Exec("SELECT 1 FROM pgstattuple('pg_class')"); err != nil {
log.WithField("db", g.name).WithError(err).Error("failed to execute pgstattuple function")
if _, err := g.db.Exec("SELECT 1 FROM pgstattuple_approx('pg_class')"); err != nil {
log.WithField("db", g.name).WithError(err).Error("failed to execute pgstattuple_approx function")
return false
}
return true
Expand Down

0 comments on commit 102860c

Please sign in to comment.