size of db instead of table

This commit is contained in:
Bel LaPointe
2025-12-08 16:16:03 -07:00
parent 7252c96dab
commit 72a63afdee

View File

@@ -7,6 +7,7 @@ import (
"fmt"
"log"
"os"
"path"
"time"
"pg/src/with"
@@ -30,8 +31,10 @@ func run(ctx context.Context) error {
return with.PSQL(ctx, *c, func(pg *sql.DB) error {
presently := func() int {
dbname := path.Base(*c)
var n2 int
if row := pg.QueryRowContext(ctx, `SELECT pg_total_relation_size('fill_with_data')/1024/1024`); row.Err() != nil {
if row := pg.QueryRowContext(ctx, `SELECT pg_database_size('`+dbname+`')/1024/1024`); row.Err() != nil {
return 0
} else if err := row.Scan(&n2); err != nil {
return 0