Distributed Characteristics of PostgreSQL

==>

1. Data Sharding (数据分区)

Data sharding is a method that involves splitting large databases into multiple smaller ones, each containing different parts of the data. This is a key technology for implementing distributed storage.

PostgreSQL supports the following data partitioning schemes:

  • Range sharding: Partitions data based on ranges. In this approach, data is divided into several segments, where each segment contains data of the same type.
  • Hash sharding: Assigns table names or primary keys to different servers using a hash function. This method is commonly used for implementing distributed storage.

PostgreSQL's data partitioning supports the following methods:

  • Range-based partitioning: Used for managing data ranges.
  • List-based partitioning: Used for managing lists of specific values.
  • Hash-based partitioning: Used to assign data using a hash function.
  • Composite partitioning: Used to partition different columns within a table.

2. Distributed Query (分布式查询)

PostgreSQL supports distributed queries, allowing complex queries to be executed across multiple databases. This technology is commonly used in large-scale applications with high real-time requirements.

Key features of Distributed Query:

  • Partition data: Divides data into different databases.
  • Use connection pooling (pooling): Reduces the overhead of establishing new connections through a connection pool.
  • Distributed transaction management: PostgreSQL supports transaction replication and failover when executing complex transactions.

3. Distributed Storage (分布式存储)

PostgreSQL supports distributed storage, allowing data to be stored across multiple servers for high availability and scalability.

Key features of Distributed Storage:

  • Data distribution: Stores data in multiple locations.
  • Replication(replication): Ensures data consistency and provides failover capabilities.
  • Replika (replica): A replica server can immediately replace the original server.

4. Distributed Transaction Management (分布式事务管理)

PostgreSQL supports distributed transaction management, enabling high reliability and failover capabilities when executing complex transactions.

Key features of Distributed Transaction Management:

  • Transaction replication: Ensures consistency of transactions and provides failover capabilities.
  • Multiple nodes: Supports execution of transactions across multiple nodes.
  • Strong consistency(consistency): Achieved by executing transactions on each node in a manner that ensures strong consistency.

5. Distributed Locking (分布式锁定)

PostgreSQL supports distributed locking, allowing transactions to be executed across multiple nodes while maintaining data consistency.

Key features of Distributed Locking:

  • Locking(locking): Used to protect resources from contention by other nodes.
  • Unlocking(unlocking): Used to release locks so that other nodes can access the resources.
  • Achieving strong consistency: Achieved by executing locks across multiple nodes in a manner that ensures strong consistency.

6. Distributed Indexing (分布式索引)

PostgreSQL supports distributed indexing, allowing data to be indexed at multiple locations to improve query efficiency.

Key features of Distributed Indexing:

  • Index distribution: Stores indexes in multiple locations.
  • Column options(columns): Supports indexing data based on different columns.
  • Achieving high performance: Improves query efficiency by executing queries across multiple nodes.