Only sometimes attempt manually computing n_distinct values

For derivation_inputs.
This commit is contained in:
Christopher Baines 2022-11-29 10:36:46 +00:00
parent 6ada1cb845
commit 9f05f5f4f9
1 changed files with 12 additions and 3 deletions

View File

@ -2142,9 +2142,18 @@ SKIP LOCKED")
"vacuuming package derivations by guix revision range table"
(vacuum-package-derivations-table conn))
(with-time-logging
"update-derivation-inputs-statistics"
(update-derivation-inputs-statistics conn))
(match (exec-query
conn
"SELECT reltuples::integer FROM pg_class WHERE relname = 'derivation_inputs'")
(((rows))
;; Don't attempt counting distinct values if there are too
;; many rows, as that is far to slow and could use up all the
;; disk space.
(when (< (string->number rows)
1000000000)
(with-time-logging
"update-derivation-inputs-statistics"
(update-derivation-inputs-statistics conn)))))
(with-time-logging
"vacuum-derivation-inputs-table"