hotamul의 개발 이야기

[GPDB] check distributed key about all tables 본문

dev/Greenplum DB

[GPDB] check distributed key about all tables

hotamul 2022. 12. 14. 13:46
SELECT
    n.nspname as schemaname,
    c.relname as tablename,
    pg_get_table_distributedby(c.oid) distributedby,
     case c.relstorage
         when 'a' then ' append-optimized'
         when 'c' then 'column-oriented'
         when 'h' then 'heap'
         when 'v' then 'virtual'
         when 'x' then 'external table'
      end as "data storage mode"
  FROM pg_class as c
 INNER JOIN pg_namespace as n
    ON c.relnamespace = n.oid
   AND nspname = '<스키마 명>'
 ORDER BY n.nspname, c.relname ;

Example SQL

SELECT
    n.nspname as schemaname,
    c.relname as tablename,
    pg_get_table_distributedby(c.oid) distributedby,
     case c.relstorage
         when 'a' then ' append-optimized'
         when 'c' then 'column-oriented'
         when 'h' then 'heap'
         when 'v' then 'virtual'
         when 'x' then 'external table'
      end as "data storage mode"
  FROM pg_class as c
 INNER JOIN pg_namespace as n
    ON c.relnamespace = n.oid
   AND nspname = 'training'
 ORDER BY n.nspname, c.relname ;

출력 결과

schemaname    tablename    distributedby    "data storage mode"
training    boys_ao    DISTRIBUTED BY (id)    heap
training    d_airlines    DISTRIBUTED BY (airlineid)    heap
training    d_airports    DISTRIBUTED BY (airport_code)    heap
training    d_cancellation_codes    DISTRIBUTED BY (cancel_code)    heap
training    d_delay_groups    DISTRIBUTED BY (delay_group_code)    heap
...
Comments