Vì Greenplum là một kiến trúc MPP nên việc phân phối dữ liệu trong tất cả các phân đoạn là điều đầu tiên.
You can distribute your table data using Distributed BY
, and if you are not sure about a particular column, you can create your table using Distributed Randomly.
Nhưng các bảng được phân phối ngẫu nhiên sẽ không tốt cho hiệu suất của bảng vì trình tối ưu hóa truy vấn sẽ mất nhiều thời gian hơn cho các bảng được phân phối ngẫu nhiên.
Greenplum DBA có thể sử dụng tập lệnh bên dưới để tìm các bảng được phân phối ngẫu nhiên.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | with cte AS ( SELECT pgn.nspname as SchemaName ,pgc.relname as TableName ,pga.attname as DistributionType FROM ( SELECT gdp.localoid, CASE WHEN ( Array_upper(gdp.attrnums, 1) > 0 ) THEN Unnest(gdp.attrnums) ELSE NULL END AS attnum FROM gp_distribution_policy gdp ORDER BY gdp.localoid ) AS distrokey INNER JOIN pg_class AS pgc ON distrokey.localoid = pgc.oid INNER JOIN pg_namespace pgn ON pgc.relnamespace = pgn.oid LEFT OUTER JOIN pg_attribute pga ON distrokey.attnum = pga.attnum AND distrokey.localoid = pga.attrelid ) select SchemaName ,TableName ,COALESCE(DistributionType,'DISTRIBUTED RANDOMLY') AS DistributionType from cte where COALESCE(DistributionType,'DISTRIBUTED RANDOMLY')='DISTRIBUTED RANDOMLY' ORDER BY SchemaName,TableName |