Skip to content

Commit

Permalink
remove select * from big tables and use statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
nopcoder committed Nov 2, 2020
1 parent 3a432c3 commit 26e2160
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions diagnostics/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func (c *Collector) Collect(ctx context.Context, w io.Writer) (err error) {
contentFromTables := []string{
"auth_installation_metadata",
"schema_migrations",
"pg_stat_database",
}
for _, tbl := range contentFromTables {
err = c.writeTableContent(ctx, writer, tbl)
Expand All @@ -48,10 +49,7 @@ func (c *Collector) Collect(ctx context.Context, w io.Writer) (err error) {
countFromTables := []string{
"catalog_branches",
"catalog_commits",
"catalog_entries",
"catalog_repositories",
"catalog_object_dedup",
"catalog_multipart_uploads",
"auth_users",
}
for _, tbl := range countFromTables {
Expand All @@ -61,12 +59,6 @@ func (c *Collector) Collect(ctx context.Context, w io.Writer) (err error) {
}
}

err = c.writeQueryContent(ctx, writer, "entries_per_branch", sq.
Select("branch_id", "COUNT(*)").From("catalog_entries").GroupBy("branch_id"))
if err != nil {
errs = append(errs, fmt.Errorf("write query entries_per_branch %w", err))
}

err = c.writeRawQueryContent(ctx, writer, "table_sizes", `
SELECT *, pg_size_pretty(total_bytes) AS total
, pg_size_pretty(index_bytes) AS INDEX
Expand Down

0 comments on commit 26e2160

Please sign in to comment.