PolarDB for PostgreSQL (Compatible with Oracle) 2.0 features a new compatibility architecture compared to version 1.0, with Oracle syntax compatibility as the development baseline. Version 2.0 delivers significant performance improvements over version 1.0 in high concurrency, high write loads, parallel queries, and logical replication under distributed load conditions. This topic describes the specific differences between the two versions for your reference. Please refer to the currently released PolarDB for PostgreSQL (Compatible with Oracle) 2.0 version (20250630). Some features will be gradually supported in future versions.
Significant performance improvements
Performance tests were conducted using pgbench for read-only scenarios (select-only) and read-write scenarios (tpcb-like) with a cluster specification of polar.o.x8.xlarge. The test results are as follows:
Scenario | PolarDB for PostgreSQL (Compatible with Oracle) 1.0 | PolarDB for PostgreSQL (Compatible with Oracle) 2.0 | Performance improvement |
Read-only scenario (select-only) | 109141.30 | 120803.95 | 10.69% |
Read-write scenario (tpcb-like) | 49226.71 | 64752.41 | 31.54% |
PolarDB for PostgreSQL (Compatible with Oracle) 2.0 demonstrates significant performance improvements compared to version 1.0, especially in tpcb-like read-write scenarios where performance has improved by over 30%. Additionally, in scenarios with many connections, PolarDB for PostgreSQL (Compatible with Oracle) 2.0 has significantly increased transaction throughput, with up to 100% improvement in test scenarios.
To further enhance performance, version 2.0 has added numerous parallel query features. For example, the RETURN QUERY in PL/pgSQL functions now supports parallel computation when returning results, and the REFRESH MATERIALIZED VIEW command can also use parallel queries. Additionally, parallel sequential scanning of chunks is supported, improving I/O throughput for large-scale data scanning, bringing it close to the I/O throughput limit of block devices.
Index enhancements
PolarDB for PostgreSQL (Compatible with Oracle) 2.0 has effectively optimized the handling of duplicate data in B-tree indexes (standard database indexes), reducing the overall space usage of B-tree indexes while improving overall query performance. Specifically, it introduces the index compression policy of deduplication technology to automatically deduplicate and compress duplicate data in B-tree indexes and reduce the space occupied by indexes. At the same time, version 2.0 also addresses resource consumption issues with B-tree indexes, including table bloat problems caused by frequent index updates.
Additionally, this version provides GiST indexes that pre-sort data during the building process, significantly improving the creation speed of GiST and SP-GiST indexes and reducing index size.
Partitioned table improvements
PolarDB for PostgreSQL (Compatible with Oracle) 2.0 has improved the partition system, resulting in better performance when querying partitioned tables. Now, you can use more flexible partition pruning and intelligent JOIN operations. Additionally, this version has enhanced support for triggers and added support for logical replication, making data replication and synchronization more efficient and reliable.
Furthermore, version 2.0 has optimized partition pruning capabilities, reducing child partition SubPlans and duplicate cached plans, allowing for faster query execution. At the same time, when adding or removing partitions, using the alter table detach|attach PARTITION concurrently mode avoids lock conflicts, improving database availability and stability.
Parallel VACUUM (garbage collection)
The VACUUM mechanism is very important in database management in PolarDB for PostgreSQL (Compatible with Oracle) 2.0, as it can release table space that is no longer in use to alleviate common table bloat problems. To further optimize the efficiency and performance of garbage collection, version 2.0 introduces a parallel index recovery mechanism. Additionally, you can specify the number of parallel workers to better meet your needs.
Through these optimizations, database management in PolarDB for PostgreSQL (Compatible with Oracle) 2.0 has higher efficiency, reliability, and stability, making it easier for you to manage and maintain your data.
Query optimization
Introduced incremental sorting, where sorted data from earlier steps in a query can accelerate sorting in subsequent steps. This optimization can significantly improve query performance and efficiency.
Added more types of aggregate and grouping set queries that can leverage PostgreSQL's efficient hash aggregation functionality. This means that queries with large aggregations do not need to be fully loaded into memory, significantly reducing memory usage and I/O overhead.
Supports
linear search TO hash table probe, which can significantly improve the processing performance of IN statements. The performance improvement is more significant, especially in SQL with multiple conditions or requiring filtering of large amounts of data.
Support for LZ4 compression algorithm and enhanced security features
PolarDB for PostgreSQL (Compatible with Oracle) 2.0 introduces several new features, including support for selecting the LZ4 algorithm for data column compression to improve compression performance, while still maintaining support for the original pglz compression method. Additionally, you can use the predefined roles pg_read_all_data and pg_write_all_data to grant read-only or write-only permissions for tables/views/sequences objects at once, providing you with more flexible data management options.
Version 2.0 adopts object permission granularity for cloud-based permission management, ensuring data security and reliability. This optimization protects sensitive data and prevents data leaks and security breaches.
Core features
Data type compatibility
Function and operator compatibility
SQL syntax compatibility
DDL syntax compatibility
Partitioned table functionality
Transaction processing capabilities
Trigger functionality
Supports DDL system triggers, facilitating the handling of DDL operation-related triggers.
Supports
ALTER TRIGGER ENABLE/DISABLEto manage system triggers, making it easier to control trigger behavior.Supports DDL system triggers at
Schema/Databaselevels, facilitating the handling of DDL operations at corresponding levels.Supports
updating('col')syntax for trigger subfunctions, facilitating complex trigger logic handling.
PL/SQL programming support
Package functionality
Supports creation and deletion of custom package functionality.
Supports common collection types such as associative arrays, nested tables, and variable-length arrays.
Supports basic initialization, calling, and assignment operations for collection types.
Supports one-dimensional
SUBTYPEin packages, extending data model support for packages.Package
recordsupportsconstraint, ensuring data integrity.Supports case-insensitive package access.
Supports package functions depending on subsequently defined types.
Supports package function stored procedures ignoring default values.
Supports using package variables to specify package function parameter types.
Supports package variables as stored procedure variables and default values for subfunction parameters.
Collection type support
Supports using associative arrays as parameters and return values, facilitating handling of complex data structures.
Supports variable-length data equivalent declarations, simplifying collection type space management logic.
The collection type range can be deleted.
Supports built-in associative arrays in built-in packages.
Supports three-dimensional associative arrays, extending collection type functionality.
Supports associative array elements as two-dimensional
record, enhancing composite type expression, and supports nesting with records.Supports
fetch bulk intotocoll(idx).recfieldcollection type, optimizing DML execution efficiency.Supports using high-dimensional collection types in DML statements.
Supports default values for collection type function parameters.
Supports associative array constructors.
Supports conversion operations and set operations for collection types.
Built-in package ecosystem
PolarDB for PostgreSQL (Compatible with Oracle) 2.0 provides a rich set of Oracle-compatible built-in packages covering various aspects of enterprise applications:
DBMS_AQ: Provides functions for message queue enqueue and dequeue operations.
DBMS_AQADM: Provides configuration and management functions for message queues.
DBMS_ALERT: Provides a set of stored procedures for registering, sending, and receiving alerts.
DBMS_APPLICATION_INFO: Records the names of modules or transactions being executed in the database for performance tracking and debugging.
DBMS_CRYPTO: Provides encryption and decryption functionality for stored data, supporting AES, DES, hashing, and message digest functions.
DBMS_DDL: Facilitates DDL-related operations.
DBMS_JOB: Used to create and manage scheduled tasks, allowing users to submit scheduled tasks to be executed in the database at scheduled times.
DBMS_LOB: Provides access and operation methods for large objects, including
BLOBandCLOB.DBMS_LOCK: Provides the built-in
SLEEPfunction to pause the current session for a period of time.DBMS_METADATA: Provides methods to obtain metadata information for database objects, used for rebuilding objects in the database.
DBMS_MVIEW: Supports
REFRESHwithout including dependent objects.DBMS_OUTPUT: Can send messages from stored procedures, packages, or triggers.
DBMS_XMLGEN: Provides
convertfunction for handling XML data conversion.DBMS_XMLPARSER: Provides parsing methods for XML documents, which can be used to generate Document objects.
DBMS_PIPE: Supports pipe communication between different sessions within the same instance.
DBMS_RANDOM: Provides a series of random functions and stored procedures.
DBMS_REDACT: Provides functions for data masking of queries by low-privilege users or applications, protecting database data security.
DBMS_RLS: Allows Virtual Private Database (VPD) to execute on specific PolarDB database objects.
DBMS_SESSION: Provides interfaces for accessing session, user, and other information from PL/SQL.
DBMS_SPACE: Facilitates space management-related operations.
DBMS_SQL: Provides interfaces for executing DML and DDL statements using dynamic SQL, executing PL/SQL anonymous blocks, and calling PL/SQL stored procedures and functions.
DBMS_TRANSACTION: Used for transaction-related operations.
DBMS_UTILITY: Provides various utility subroutines, package dependency retrieval.
DBMS_XMLDOM: Provides DOM access interfaces for XML documents, supporting the definition and generation of various DOM objects.
UTL_ENCODE: Provides a set of functions for data encoding and decoding, facilitating data transmission between different hosts.
UTL_I18N: Provides services consisting of
ESCAPE_REFERENCEandUNESCAPE_REFERENCEfunctions, providing additional globalization capabilities for applications written in PL/SQL.UTL_MATCH: Enhances string pattern matching functionality, simplifying text operation processes.
UTL_HTTP: Extends Web interaction functionality.
UTL_RAW: Provides functions for manipulating RAW type data.
UTL_TCP: Strengthens TCP communication functionality, expanding network transmission scenarios.
UTL_URL: Provides methods for converting invalid characters and reserved characters in URLs.
System view compatibility
Supports Oracle common views such as
ALL_PART_KEY_COLUMNS,USER_PART_KEY_COLUMNS,DBA_PART_KEY_COLUMNS,DBA_ROLE_PRIVS,USER_ROLE_PRIVS.Supports
DBA_COL_COMMENTSview for viewing and managing column comment information.Supports
nlsparameter views, extending support for internationalization parameters, enhancing multilingual configuration management.Supports
DBA_TAB_COLUMNSview with all parameters, providing more comprehensive table column information.Supports
SESSION_ROLEbuilt-in view, extending session role management functionality.Supports
USER_TAB_PARTITIONSviewHIGH_VALUEfield, optimizing partition table high value management.Supports
DBA_OBJECTSviewCREATEDfield for viewing object creation time.
Other advanced features
Syntax compatibility differences
PolarDB for PostgreSQL (Compatible with Oracle) 2.0 has the following differences compared to version 1.0:
Type | Description |
Data types | Does not support |
DDL syntax |
|
Views and partitioned tables |
|
Functions, stored procedures, and triggers |
|
Transactions | If a write operation occurs in an autonomous transaction, the transaction must be explicitly committed or rolled back. Otherwise, the transaction fails. |
SQL queries |
|
Packages |
|
PL/SQL and collection types |
|