View column statistics
Base statistics
Section titled “Base statistics”SELECT tablename, attname, null_frac, avg_width, n_distinct, correlationFROM pg_statsWHERE tablename = 'flight' AND attname = 'departure_airport';tablename | attname | null_frac | avg_width | n_distinct | correlation-----------+-------------------+-----------+-----------+------------+-------------flight | departure_airport | 0 | 4 | 647 | 0.049104065(1 row)
Common values info
Section titled “Common values info”WITH s AS ( SELECT most_common_vals, most_common_freqs FROM pg_stats WHERE tablename = 'flight' AND attname = 'departure_airport')
SELECT value, ROUND((ratio * 100)::numeric, 2) AS pct, ratioFROM unnest( (SELECT most_common_vals::text::text [] FROM s), (SELECT most_common_freqs FROM s) ) AS x (value, ratio)ORDER BY ratio DESC;value | pct | ratio-------+------+--------------ATL | 2.33 | 0.023333333ORD | 1.99 | 0.019933334DEN | 1.79 | 0.0179LAX | 1.76 | 0.017633334CDG | 1.64 | 0.016366666...(100 rows)