分布

使用状況

ビュー: my_view {
derived_table: {
distribution: "customer_id"
...
}
}
階層
distribution

または

distribution
デフォルト値
なし

許可
派生テーブルまたは集計テーブルの列の名前

特別なルール
distribution は、Redshift と Aster のデータベースでのみサポートされています。

定義

distribution を使用すると、永続派生テーブル(PDT)または集計テーブルから列を指定して、分散キーを適用してクラスタ全体にデータを分散できます。distribution パラメータで指定された列で 2 つのテーブルが結合されると、データベースは同じノード上で結合されたデータを検出し、ノード間 I/O を最小限に抑えることができます。現在、distribution は Redshift と Aster のデータベースでのみ機能します。その他の SQL 言語(MySQL や Postgres など)の場合は、代わりに indexes を使用します。

distribution パラメータは、PDT や集計テーブルなど、永続なテーブルでのみ機能します。distribution は、永続化戦略のない派生テーブルではサポートされていません。

また、distribution パラメータは、create_process または sql_create を使用して定義された派生テーブルではサポートされていません。

一般に、分散キーは、外部キーとして機能する列(テーブルを他のユーザーとの結合に使用する列)に適用する必要があります。ベスト プラクティスについては、使用するドキュメントをご覧ください。

customer_id に配布キーを使用して、customer_order_facts 永続的な派生テーブルを作成します。

view: customer_order_facts {
  derived_table: {
    explore_source: order {
      column: customer_id { field: order.customer_id }
      column: lifetime_orders { field: order.lifetime_orders }
    }
    datagroup_trigger: order_datagroup
    distribution: "customer_id"
  }
}

customer_id に分散キーを指定して SQL クエリに基づき customer_order_facts 派生テーブルを作成します。

view: customer_order_facts {
  derived_table: {
    sql:
      SELECT
        customer_id,
        COUNT(*) AS lifetime_orders
      FROM
        order ;;
    persist_for: "24 hours"
    distribution: "customer_id"
  }
}