Yandex Cloud
Search
Discuss with expertTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
    • Cloud Interconnect
    • Cloud Backup
    • Cloud Registry
    • Yandex AI Studio
    • Compute Cloud
    • Object Storage
    • Managed Service for Kubernetes®
    • Yandex BareMetal
    • Smart Web Security
    • Security Deck
    • Managed Service for PostgreSQL
    • Managed Service for ClickHouse®
    • Monium
    • Cloud CDN
    • Network Load Balancer
    • Virtual Private Cloud
    • Cloud DNS
    • Application Load Balancer
    • Yandex Cloud Video
    • Stackland
    • Yandex Cloud Router
    • Yandex Managed Service for Trino
    • Managed Service for MySQL®
    • Managed Service for Valkey™
    • Managed Service for Apache Spark™
    • Yandex StoreDoc
    • Managed Service for OpenSearch
    • Managed Service for Apache Kafka®
    • Data Transfer
    • Yandex MPP Analytics Engine for PostgreSQL
    • Yandex Managed Service for Apache Airflow®
    • Data Processing
    • Yandex MetaData Hub
    • Managed Service for YDB
    • Managed Service for Sharded PostgreSQL
    • Managed Service for YTsaurus
    • Yandex WebSQL
    • DataLens
    • Yandex Search API
    • SpeechSense
    • SpeechKit
    • DataSphere
    • Vision OCR
    • Translate
    • Yandex Identity Hub
    • Key Management Service
    • Certificate Manager
    • Yandex Lockbox
    • Audit Trails
    • SmartCaptcha
    • Cloud Desktop
    • Yandex SIEM
    • SourceCraft Code Assistant
    • Container Registry
    • Managed Service for GitLab
    • Managed Service for Prometheus®
    • Cloud Functions
    • API Gateway
    • Yandex Cloud Postbox
    • Message Queue
    • Serverless Integrations
    • IoT Core
    • Data Streams
    • Serverless Containers
    • Cloud Notification Service
    • Yandex Query
    • Identity and Access Management
    • Yandex Cloud Console
    • Resource Manager
    • Yandex Cloud Billing
    • Yandex Cloud Quota Manager
    • Cloud Apps
  • System Status
  • Marketplace
    • Featured
    • Infrastructure & Network
    • Data Platform
    • AI for business
    • Security
    • DevOps tools
    • Serverless
    • Monitoring & Resources
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2026 Direct Cursus Technology L.L.C.
Yandex MPP Analytics for PostgreSQL
  • Getting started
    • All guides
      • Managing databases
      • Queries in Yandex WebSQL
      • Working with data distribution policies
    • Connecting to an external file server (gpfdist)
    • Auxiliary utilities
  • Access management
  • Inspections and recommendations
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Public materials
  • Release notes

In this article:

  • Defining a distribution policy
  • Modifying a distribution policy
  • Redistributing data manually
  1. Step-by-step guides
  2. Databases
  3. Working with data distribution policies

Working with data distribution policies in Yandex MPP Analytics for PostgreSQL

Written by
Yandex Cloud
Updated at September 23, 2026
View in Markdown
  • Defining a distribution policy
  • Modifying a distribution policy
  • Redistributing data manually

In Yandex MPP Analytics for PostgreSQL, all database tables are distributed row by row across the cluster's segment hosts. Each table is assigned a data distribution policy that defines the specific rule used to allocate rows to segments. For more on distribution policies, see Data distribution in Yandex MPP Analytics for PostgreSQL.

When working with data distribution policies, you can:

  • Define a distribution policy for a new table.
  • Modify the distribution policy and key for an existing table.
  • Manually redistribute data across segments.

Defining a distribution policyDefining a distribution policy

SQL

To define a distribution policy, run this command:

  • For hash distribution:

    CREATE TABLE <table_name> (
      <column_descriptions>
    ) DISTRIBUTED BY (<distribution_key>);
    

    Where <distribution_key> is a single column or a comma-separated list of columns.

  • For random distribution:

    CREATE TABLE <table_name> (
      <column_descriptions>
    ) DISTRIBUTED RANDOMLY;
    
  • For replicated distribution:

    CREATE TABLE <table_name> (
      <column_descriptions>
    ) DISTRIBUTED REPLICATED;
    

Modifying a distribution policyModifying a distribution policy

Warning

If a table has a primary key or a unique constraint, you cannot change its distribution policy from hash distribution to random distribution.

SQL

To modify a distribution policy or key, run this command:

  • Changing to hash distribution or selecting a new distribution key:

    ALTER TABLE <table_name>
    SET DISTRIBUTED BY (<distribution_key>);
    

    Where <distribution_key> is a single column or a comma-separated list of columns.

  • Changing to random distribution:

    ALTER TABLE <table_name>
    SET DISTRIBUTED RANDOMLY;
    
  • Changing to replicated distribution:

    ALTER TABLE <table_name>
    SET DISTRIBUTED REPLICATED;
    

When you modify a policy, data is automatically redistributed across segments, except in the following cases:

  • When changing the policy from hash distribution to random distribution.
  • When the DISTRIBUTED clause specifies the current distribution policy settings.

If needed, you can manually redistribute data.

Redistributing data manuallyRedistributing data manually

SQL

To redistribute data, e.g., when changing the policy from hash distribution to random distribution, run this command:

ALTER TABLE <table_name>
SET WITH (REORGANIZE=TRUE);

When expanding a Yandex MPP Analytics for PostgreSQL cluster, data is redistributed automatically, so you do not need to run this command manually.

Was the article helpful?

Previous
Queries in Yandex WebSQL
Next
Role and user management
© 2026 Direct Cursus Technology L.L.C.