Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: speed up get row count estimate of a pg table (#2400)
h3n4la4ee40df0e92
diff --git a/plugin/db/pg/sync.go b/plugin/db/pg/sync.goindex a223cd1f4f..4ab2e0e6f1 100644--- a/plugin/db/pg/sync.go+++ b/plugin/db/pg/sync.go@@ -377,7 +377,7 @@ func getPgTables(txn *sql.Tx) ([]*tableSchema, error) {}func getTable(txn *sql.Tx, tbl *tableSchema) error {- countQuery := fmt.Sprintf(`SELECT COUNT(1) FROM "%s"."%s";`, tbl.schemaName, tbl.name)+ countQuery := fmt.Sprintf(`SELECT GREATEST(reltuples::bigint, 0::BIGINT) AS estimate FROM pg_class WHERE oid = (quote_ident('%s') || '.' || quote_ident('%s'))::regclass;`, tbl.schemaName, tbl.name)rows, err := txn.Query(countQuery)if err != nil {return err