GP Database Distribution key Query

Source: Internet
Author: User

The tables in the GP database generally set the distribution key, which, if not set, is usually the first field by default, so it is generally recommended that a single record be used as the distribution key, so that the records in the table are evenly distributed across each segment.

GP Database Distribution key Query method:

select c.schema_name,       c.table_name,        c.table_comment as  "Chinese show",        c.column_name  as  "Distribution Key",  from  ( select d.nspname as schema_name,                 c.relname as  Table_name,                obj _description (c.oid)  as table_comment,                 a.attname as column_name            from pg_class c            left join pg_attribute a              on a.Attrelid = c.oid           join pg_ Namespace d             on d.oid  = c.relnamespace           left join  pg_inherits f             on  C.oid = f.inhrelid          where a.attnum  > 0            and f.inhrelid  is null) c  join  (select a.attrnums[i.i] as a.attrnums,                b.attname,                a.localoid::regclass as  localoid          from gp_distribution_policy a,                 (Select generate_series (1,10)  as generate _series)  i (i),                Pg_attribute b        where a.attrnums[i.i] is not  null          and a.localoid =  b.attrelid          and a.attrnums[i.i] =  B.attnum)  t    on c.column_name = t.attname   and  ((c.schema_name::text | |   '. ':: text)  | |  a.table_name::text):: Regclass::oid = t.localoid::oid order by c.schema_name,           c.table_name,          c.column_name; 

GP Database Distribution key Query

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.