1、查看greenplum分布键
SELECT n.nspname,c.relname,
CASE
WHEN length(dist_col) > 0 THEN
dist_col
END as distribution_key
FROM pg_class c, pg_namespace n,
(SELECT pc.oid,
string_agg(attname, ', ' order by colorder) AS dist_col
FROM pg_class AS pc
LEFT JOIN (SELECT localoid,
unnest(attrnums) as colnum,
generate_series(1, array_upper(attrnums, 1)) as colorder
FROM gp_distribution_policy
) AS d
ON (d.localoid = pc.oid)
LEFT JOIN pg_attribute AS a
ON (d.localoid = a.attrelid AND d.colnum = a.attnum)
GROUP BY
pc.oid
) AS keys
WHERE c.oid = keys.oid
AND c.relnamespace = n.oid
AND c.relkind='r'
--AND c.relstorage='h'
-- Following filter takes out all partitions, we care just about master table
AND c.oid NOT IN (SELECT inhrelid FROM pg_inherits)
AND n.nspname = 'ods'
and c.relname='test';