Redshift Research Project

System Table Tracker

System Table Version 1.0.41533 / 2022-09-18

schema name column data type
pg_catalog pg_stats attname name
pg_catalog pg_stats avg_width int4
pg_catalog pg_stats correlation float4
pg_catalog pg_stats histogram_bounds anyarray
pg_catalog pg_stats most_common_freqs float4[]
pg_catalog pg_stats most_common_vals anyarray
pg_catalog pg_stats n_distinct float4
pg_catalog pg_stats null_frac float4
pg_catalog pg_stats schemaname name
pg_catalog pg_stats tablename name

View Text

SELECT n.nspname AS schemaname,
       c.relname AS tablename,
       a.attname,
       s.stanullfrac AS null_frac,
       s.stawidth AS avg_width,
       s.stadistinct AS n_distinct,
       CASE
         WHEN 1 = s.stakind1
           THEN s.stavalues1
         WHEN 1 = s.stakind2
           THEN s.stavalues2
         WHEN 1 = s.stakind3
           THEN s.stavalues3
         WHEN 1 = s.stakind4
           THEN s.stavalues4
         ELSE CAST(NULL AS unknown)
       END AS most_common_vals,
       CASE
         WHEN 1 = s.stakind1
           THEN s.stanumbers1
         WHEN 1 = s.stakind2
           THEN s.stanumbers2
         WHEN 1 = s.stakind3
           THEN s.stanumbers3
         WHEN 1 = s.stakind4
           THEN s.stanumbers4
         ELSE CAST(NULL AS real[])
       END AS most_common_freqs,
       CASE
         WHEN 2 = s.stakind1
           THEN s.stavalues1
         WHEN 2 = s.stakind2
           THEN s.stavalues2
         WHEN 2 = s.stakind3
           THEN s.stavalues3
         WHEN 2 = s.stakind4
           THEN s.stavalues4
         ELSE CAST(NULL AS unknown)
       END AS histogram_bounds,
       CASE
         WHEN 3 = s.stakind1
           THEN (s.stanumbers1)[1]
         WHEN 3 = s.stakind2
           THEN (s.stanumbers2)[1]
         WHEN 3 = s.stakind3
           THEN (s.stanumbers3)[1]
         WHEN 3 = s.stakind4
           THEN (s.stanumbers4)[1]
         ELSE CAST(NULL AS real)
       END AS correlation
FROM pg_statistic AS s
     INNER JOIN pg_class AS c ON c.oid = s.starelid
     INNER JOIN pg_attribute AS a ON c.oid = a.attrelid
                                 AND a.attnum = s.staattnum
     LEFT JOIN pg_namespace AS n ON n.oid = c.relnamespace
WHERE has_table_privilege(c.oid,
                          CAST('select' AS text))


Home 3D Друк Blog Bring-Up Times Consultancy Cross-Region Benchmarks Email Forums IRC Mailing Lists Reddit Redshift Price Tracker Redshift Version Tracker Redshift Workbench System Table Tracker The Known Universe Twitter White Papers