Introduction: The Architectural Foundation of Distributed Databases
Compared with centralized databases, distributed relational databases offer greater scalability and availability by distributing data and workloads across multiple nodes. They also need to support enterprise requirements such as financial-grade high availability, transparent horizontal scaling, distributed transactions, and multi-tenancy.
A common approach is the shared-nothing architecture. Each node operates with its own CPU, memory, and local storage, while multiple nodes work together as a cluster. This architecture uses general-purpose server hardware without requiring specialized equipment, allowing database capacity to expand as workloads grow.

Storage Architecture
The storage engine uses an LSM-Tree architecture based on baseline and incremental data. Data is managed through two main structures: SSTables and MemTables.
Baseline and Incremental Data
- SSTable: Stores relatively stable baseline data on disk. It is read-only and is not modified after being generated.
- MemTable: Stores incremental data in memory and supports read and write operations.
When the database executes DML operations such as INSERT, UPDATE, and DELETE, changes are first written to the MemTable. When the MemTable reaches a certain size, its contents are flushed to disk and converted into an SSTable.
Because the LSM-Tree design avoids repeatedly updating existing disk data, it also creates opportunities for more efficient data encoding and compression. By combining proprietary row-column hybrid encoding with general-purpose compression algorithms, storage compression can exceed 10 times that of traditional databases under certain conditions, potentially saving more than 70% of storage space.
Row Store, Column Store, and Hybrid Row-Column Storage
Starting with OceanBase V4.3, baseline data supports row storage, column storage, and hybrid row-column storage, while incremental data remains in row format.
- Row storage: Stores the fields of a record together, making it suitable for transactional operations that frequently access or modify complete records.
- Column storage: Organizes data by column, making it suitable for analytical queries that scan specific columns.
- Hybrid row-column storage: Combines the characteristics of both formats to accommodate different data access patterns.
By supporting different storage formats for baseline data while retaining row storage for incremental data, the same storage engine can support both TP transactions and AP analytical workloads.
Replica Management and High Availability
Replica Types and Locality
The database supports three main replica types:
- Full-featured replicas
- Log-only replicas
- Read-only replicas
Locality describes the replica types configured for a tenant or table and how those replicas are distributed across different Zones and Regions. It defines the physical distribution of replicas and provides a basis for configuring high availability and disaster recovery.
Paxos-Based Replication and Consistency
Replicas belonging to the same Log Stream use the Paxos protocol to maintain strong consistency.
The Leader is responsible for coordinating log replication and handling strong-consistency reads and writes. Followers participate in log replication and can serve weak-consistency read requests when the relevant configuration allows it.
A majority of replicas must synchronously persist the corresponding Clog before a log entry is committed. This majority-based mechanism helps prevent data loss caused by individual hardware failures.
Distributed Election and Failure Recovery
When a minority of replicas fails, the remaining majority can continue providing database services. If the Leader fails, the surviving replicas initiate an election to select a new Leader.
When half or more of the replicas become unavailable, or network isolation makes it difficult to determine the cluster's actual status, an external arbitration service can participate in the decision-making process. This helps prevent split-brain situations and supports cluster recovery.
Disaster Recovery Architectures
For disaster recovery, common deployment architectures include:
- Dual data centers within the same city.
- Two-region, three-data-center architecture.
These configurations support high availability across data centers and cities, helping maintain database services when a data center or geographic location becomes unavailable.
Distributed Query Optimization and Execution Engine
Based on the shared-nothing architecture, the database supports distributed execution plan generation and execution. Since relational table data is distributed across partitions on different nodes, queries involving multiple partitions may require operations across several nodes.
The optimizer generates a distributed execution plan according to the SQL statement and the physical distribution of data.
Distributed Execution Plans
A distributed execution plan determines how query operations are executed across different nodes and how intermediate results are exchanged.
Partition selection and partition pruning help reduce unnecessary data access. When query conditions include the partition key, the database can identify the relevant partitions and avoid scanning unrelated data.
Parallel Query Execution
A query plan can be divided into multiple Data Flow Operations (DFOs), which are executed concurrently by multiple execution threads.
Parallel execution includes both concurrency between different DFOs and concurrency within individual DFOs. This improves CPU and I/O resource utilization and can reduce the response time of individual queries.
The performance benefits are particularly noticeable when I/O bandwidth is sufficient and CPU utilization is relatively low.

Distributed Query Optimization Strategies
Partitioning and Table Group Optimization
- Partition pruning: For large tables, select partition keys according to common business access patterns. This allows most queries to use the partition key for partition pruning and reduces the amount of data scanned.
- Reducing cross-node communication: Related tables can use their join keys as partition keys and adopt the same partitioning strategy. A Table Group can place corresponding partitions on the same node, reducing data exchange during joins.
- Table Group adjustment: In OceanBase V4.x, Table Groups, including ADAPTIVE Table Groups, can be adjusted to optimize data distribution. After tables with the same partitioning rules are added to a Table Group, a load balancing task generally needs to be triggered manually.
Selecting and Adjusting the Degree of Parallelism (DOP)
An inappropriate DOP can affect query performance:
- If the DOP is too low, system resources may be underutilized, resulting in longer query execution times.
- If the DOP is too high, resource contention may increase and overall throughput may decrease.
Monitor execution plans, query response times, and resource utilization to determine an appropriate DOP. The PARALLEL Hint can specify the DOP for distributed execution.

Managing Execution Plans with Hints
The distributed execution framework supports hints such as ORDERED, LEADING, USE_NL, USE_HASH, and USE_MERGE.
These hints influence join order and join algorithms, allowing execution plans to be adjusted according to query requirements and data distribution.
Avoiding Uneven Read Routing
When using weak-consistency read hints, pay attention to the length and ordering of SQL Outline Data.
If Outline Data is too long and OBProxy truncates the SQL statement, the proxy may fail to recognize the weak-consistency read hint or table name. As a result, the request may be routed as a strong-consistency read to the Primary Zone.
This can concentrate distributed query traffic on a single cluster node, resulting in uneven load distribution and high CPU utilization.
Distributed Transactions and Performance Tuning
Transaction Types
OceanBase transaction types are mainly determined by the location of the transaction session and the number of Log Stream Leaders involved.
Transactions can be broadly classified into single-Log-Stream transactions and distributed transactions.
- Internal distributed transactions: Transactions executed within an OceanBase cluster that involve multiple participants but belong to only one tenant.
- XA transactions: Global transactions that access multiple databases. A distributed transaction manager uses the XA interface to coordinate transaction execution and ensure atomic commits across databases.
Two-Phase Commit and Atomicity
Distributed transactions must maintain ACID properties even when transaction participants are located on different machines. The database uses the two-phase commit (2PC) protocol to ensure atomicity.
In the XA model, the Transaction Manager (TM) coordinates multiple Resource Managers (RMs), such as OceanBase database instances.
The process consists of two phases:
Prepare phase: The TM sends an XA prepare request to all participating RMs. Each RM prepares its part of the transaction and returns the result.
Commit phase: If all participants prepare successfully, the TM sends an XA commit request to complete the transaction. If the required conditions are not met, the transaction is rolled back according to the protocol.
If the TM does not receive all required responses, the transaction outcome cannot be determined from the available responses alone. Recovery procedures are needed to resolve the transaction status.
High Availability and Leader Switch Optimization
A Leader switch may occur while a transaction is in progress. The database attempts to avoid unnecessary rollbacks during Leader re-election.
If the logs of an in-flight transaction on the previous Leader are synchronized to the new Leader within a configured threshold, such as trx_force_kill_threshold (100 ms by default in the described configuration), the new Leader can continue processing the transaction. Otherwise, the in-progress transaction may be rolled back.
Paxos majority consensus ensures that only one valid Leader is elected, preventing split-brain situations.
Distributed Transaction Performance Tuning
The main objectives of distributed transaction tuning are to increase QPS and TPS while reducing response time (RT).
Optimize Transaction Architecture and Data Placement
- Single-Log-Stream transaction architecture: Starting with OceanBase V4.0, changes to the transaction architecture support single-Log-Stream transaction processing. When all Log Stream Leaders involved in a transaction are located on the same machine, the transaction uses the single-Log-Stream transaction path by default. This avoids cross-machine coordination and typically provides the highest performance among the relevant transaction paths. No additional configuration is required.
- Primary Zone configuration: When the Primary Zone is configured as RANDOM, table Leaders within a tenant may be distributed randomly across nodes, increasing the likelihood of cross-machine distributed transactions. Appropriate Primary Zone planning can help reduce this situation.
Optimize SQL and Application Design
- Specify partition keys: For business tables distributed across multiple partitions, an UPDATE statement without a partition key may involve many participants. Under high concurrency, this increases communication between participants and the coordinator, network traffic, and RPC workload. It may also cause Clog synchronization requests to accumulate and delay transaction commits. Include partition keys in SQL statements whenever possible.
- Adjust DOP: A DOP that is too low may underutilize system resources, while an excessively high DOP may increase resource contention and reduce throughput. Adjust parallelism according to query requirements and available resources.
Conclusion and Future Outlook
The implementation of a distributed DBMS involves several interconnected technical challenges, including storage management, computing resource coordination, high availability, and distributed transaction processing.
An effective distributed database architecture must balance scalability, consistency, availability, and performance while coordinating operations across multiple nodes.
As data requirements continue to evolve, multi-model data processing will become an important direction for distributed database development. Supporting different data models and processing requirements within a distributed architecture can help address increasingly diverse enterprise workloads.
To explore OceanBase's distributed DBMS capabilities firsthand, try the OceanBase Demo or visit the OceanBase documentation.






