Overview
In a distributed database, a SQL statement may be logically correct and still perform poorly because of inefficient data distribution. Common problems include:- Join columns that do not align with distribution keys
- Large Shuffle / Redistribute operations between nodes
- Small tables that are not replicated
- Predicates that are not pushed down
- Data skew caused by poor distribution-key selection
- Inefficient use of global or local indexes
Why Distributed SQL Needs Specialized Optimization
Traditional SQL optimization focuses on:- Indexes
- Join algorithms
- Scan types
- Predicate pushdown
- Aggregation and sorting
- Which node owns the data?
- Can the join be completed locally?
- Must data move between nodes?
- Which side is suitable for broadcast?
- Does the distribution key match the dominant access pattern?
- Is data heavily skewed?
Key Capabilities
Distribution key analysis
Evaluate whether table distribution keys align with common filter conditions, join predicates, and access patterns. Typical issues include:- Frequently joined tables using unrelated distribution keys
- Filters that do not benefit from the distribution strategy
- Low-cardinality distribution keys
- Hot partitions or node-level skew
Cross-shard join detection
Identify joins that require data to cross shards or nodes. For large business tables, cross-shard joins can introduce:- Network transfer
- Shuffle
- Intermediate-result explosion
- Coordinator pressure
Data movement analysis
Identify execution-plan operators such as:- Redistribute
- Broadcast
- Exchange
- Motion
- Shuffle
Replicated table recommendation
For relatively small tables that are frequently joined, such as configuration, dimension, or parameter tables, PawSQL can evaluate whether replicated or broadcast-table designs are more appropriate. Potential benefits include:- Fewer cross-node joins
- Lower network overhead
- Better join pushdown
Predicate and join pushdown
Analyze whether filters and joins can be pushed closer to the data nodes to reduce intermediate row volume.Global and local index analysis
For databases that support global and local indexes, PawSQL can evaluate:- Index coverage
- Partition / shard access paths
- Global-index maintenance cost
- Whether local indexes satisfy the query pattern
Common Optimization Strategies
Example
Suppose two large distributed tables use different distribution keys:- Changing the distribution key
- Reducing the joined data set using filters
- Broadcasting the smaller side
- Rewriting or decomposing the SQL to reduce data movement
- Introducing an additional replica or replicated table
Supported Scenarios
Distributed SQL Optimization applies to distributed database environments such as:- TDSQL PostgreSQL
- TDSQLx-MySQL
- OceanBase
- GaussDB
- openGauss
- PolarDB-X
- GoldenDB
- Greenplum