#!/bin/awk #psql:reltuples_analyze_bug.sql:45: INFO: analyzing "public.reltuples_test" #psql:reltuples_analyze_bug.sql:45: INFO: "reltuples_test": scanned 3000 of 284262 pages, containing 106269 live rows and 103740 dead rows; 3000 rows in sample, 10069413 estimated total rows function unquote(s) { return (s ~ "^\".*\"$") ? substr(s, 2, length(s)-2) : s } BEGIN { print " / estimated rows / / pages / /sampled rows/" print " relname current proposed total scanned live dead" } # capture result and match with saved schema name /INFO: ".*": scanned / { relname = unquote(substr($3, 1, length($3)-1)) schema = analyzing[relname] scanned = $5 pages = $7 live = $10 dead = $14 # sampled = $17 estimated = $21 new_estimate = int(pages/scanned * live) printf("%s%10d%10d %7d%7d %8d%8d\n", relname, estimated, new_estimate, pages, scanned, live, dead) }