Skip to Main Content
PostgreSQL 10 High Performance - Third Edition
book

PostgreSQL 10 High Performance - Third Edition

by Enrico Pirozzi
April 2018
Intermediate to advanced content levelIntermediate to advanced
508 pages
15h 22m
English
Packt Publishing
Content preview from PostgreSQL 10 High Performance - Third Edition

Viewing and estimating with statistics

The statistics information collected for each table is easiest to see using the pg_stats view. The amount of information it returns is a bit overwhelming though, and not well suited to the standard display format. The following script is named table-stats.sh in the book's file set, and it tries to display the statistics information for a particular table (with an optional database too) in a way that makes the information as readable as possible:

 #!/bin/bash if [ -z "$1" ]; then echo "Usage: table-stats.sh table [db]" exit 1 fi TABLENAME="$1" if [ -n "$2" ] ; then DB="-d $2" fi PSQL="psql $DB -x -c " $PSQL " SELECT tablename,attname,null_frac,avg_width,n_distinct,correlation, most_common_vals,most_common_freqs,histogram_bounds ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

PostgreSQL: Up and Running, 3rd Edition

PostgreSQL: Up and Running, 3rd Edition

Regina O. Obe, Leo S. Hsu
Learn PostgreSQL - Second Edition

Learn PostgreSQL - Second Edition

Luca Ferrari, Enrico Pirozzi
PostgreSQL, Second Edition

PostgreSQL, Second Edition

Korry Douglas, Susan Douglas

Publisher Resources

ISBN: 9781788474481Supplemental Content