size of db instead of table
parent
7252c96dab
commit
72a63afdee
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"pg/src/with"
|
"pg/src/with"
|
||||||
|
|
@ -30,8 +31,10 @@ func run(ctx context.Context) error {
|
||||||
|
|
||||||
return with.PSQL(ctx, *c, func(pg *sql.DB) error {
|
return with.PSQL(ctx, *c, func(pg *sql.DB) error {
|
||||||
presently := func() int {
|
presently := func() int {
|
||||||
|
dbname := path.Base(*c)
|
||||||
|
|
||||||
var n2 int
|
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
|
return 0
|
||||||
} else if err := row.Scan(&n2); err != nil {
|
} else if err := row.Scan(&n2); err != nil {
|
||||||
return 0
|
return 0
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue