Skip to content

Commit 3e4ef50

Browse files
committed
Fix index bloat query
1 parent 92b3876 commit 3e4ef50

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

index.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,9 @@ func (in *Insight) idxBloat(args []string) {
250250
AND s.tablename = tbl.relname AND s.inherited=false AND s.attname=att.attname
251251
LEFT JOIN pg_class AS toast ON tbl.reltoastrelid = toast.oid
252252
WHERE att.attnum > 0 AND NOT att.attisdropped
253-
AND tbl.relkind = 'r' And schemaname NOT IN ('pg_catalog', 'information_schema')
253+
AND tbl.relkind = 'r'
254254
GROUP BY 1,2,3,4,5,6,7,8,9,10, tbl.relhasoids
255-
ORDER BY 2,3
255+
ORDER BY 2,3 LIMIT 15
256256
) AS s
257257
) AS s2
258258
) AS s3;
@@ -278,6 +278,10 @@ func (in *Insight) idxBloat(args []string) {
278278
log.Fatal(err)
279279
os.Exit(1)
280280
}
281+
if len(results) == 0 {
282+
fmt.Println("No bloat found")
283+
os.Exit(0)
284+
}
281285
t := gotabulate.Create(results)
282286
t.SetHeaders([]string{"Database", "Schema Name", "Table", "Real Table Size",
283287
"Extra Size", "Extra Ratio %", "Fillfactor", "Bloat Size", "Bloat Ratio %", "Not Applicable?"})

0 commit comments

Comments
 (0)