PolarDB for PostgreSQL (Compatible with Oracle) 2.0 introduces a redesigned compatibility architecture with Oracle syntax as the development baseline. Compared to 1.0, version 2.0 delivers measurable performance gains in high concurrency, write-heavy, parallel query, and distributed replication workloads. This topic covers the key differences to help you evaluate migrating to 2.0.
This topic reflects the currently released version (20250630). Some features listed here will be available in future releases.
Performance improvements
Benchmarks using pgbench on a polar.o.x8.xlarge cluster show the following results:
| Scenario | Version 1.0 | Version 2.0 | Improvement |
|---|---|---|---|
| Read-only (select-only) | 109,141.30 | 120,803.95 | 10.69% |
| Read-write (tpcb-like) | 49,226.71 | 64,752.41 | 31.54% |
In high-connection scenarios, transaction throughput increases by up to 100%.
Version 2.0 also expands parallel query support:
-
RETURN QUERYin PL/pgSQL functions supports parallel computation. -
REFRESH MATERIALIZED VIEWuses parallel queries. -
Parallel sequential scanning of chunks improves I/O throughput for large-scale data scans, approaching the I/O limit of block devices.
Index enhancements
Version 2.0 optimizes B-tree index handling of duplicate data through deduplication, which automatically removes repeating entries to reduce index size and improve query performance. It also addresses table bloat caused by frequent index updates.
GiST and SP-GiST indexes now pre-sort data during the build phase, resulting in faster index creation and smaller index sizes.
Partitioned table improvements
Partition pruning is more efficient: version 2.0 reduces child partition SubPlans and duplicate cached plans, speeding up query execution. Use ALTER TABLE DETACH|ATTACH PARTITION CONCURRENTLY to add or remove partitions without lock conflicts.
Additional improvements include:
-
Smarter partition pruning and more flexible JOIN operations on partitioned tables.
-
Enhanced trigger support for partitioned tables.
-
Logical replication support for partitioned tables.
Parallel VACUUM
Version 2.0 introduces a parallel index recovery mechanism for VACUUM (garbage collection), allowing multiple index-recovery workers to run concurrently. Specify the number of parallel workers to match your workload requirements.
Query optimizer enhancements
-
Incremental sorting: sorted intermediate results from earlier query steps accelerate subsequent sort operations, improving query efficiency.
-
Hash aggregation expansion: more aggregate and grouping set queries can use hash aggregation, reducing memory consumption and I/O overhead for large aggregations.
-
IN-clause optimization: linear search to hash table probe improves performance for
INclauses, especially in queries with multiple conditions or large filter sets.
Compression and security
Version 2.0 adds LZ4 as an option for column-level data compression alongside the original pglz method.
For permission management, use the predefined roles pg_read_all_data and pg_write_all_data to grant read-only or write-only access across all tables, views, and sequences at once. Permission management is now enforced at object-level granularity for cloud-based access control.
Core feature compatibility
Data type compatibility
Function and operator compatibility
SQL syntax compatibility
DDL syntax compatibility
Partitioned table functionality
Transaction processing
Triggers
-
DDL system triggers at schema and database levels.
-
ALTER TRIGGER ENABLE/DISABLEto manage system triggers. -
UPDATING('col')syntax for trigger subfunctions.
PL/SQL programming
Package functionality
-
Custom package creation and deletion.
-
Collection types: associative arrays, nested tables, and variable-length arrays (varrays).
-
Basic initialization, assignment, and calling of collection types.
-
One-dimensional
SUBTYPEin packages. -
RECORDtypes withCONSTRAINTin packages. -
Case-insensitive package access.
-
Package functions depending on types defined later in the package.
-
Package function stored procedures ignoring default values.
-
Package variables as parameter type specifiers.
-
Package variables as stored procedure variables and subfunction parameter defaults.
Collection types
-
Associative arrays as parameters and return values.
-
Variable-length data equivalent declarations.
-
Range deletion for collection type elements.
-
Built-in associative arrays in built-in packages.
-
Three-dimensional associative arrays.
-
Associative array elements as two-dimensional
recordtypes, including nesting with records. -
FETCH BULK INTOtocoll(idx).recfieldcollection type for DML efficiency. -
High-dimensional collection types in DML statements.
-
Default values for collection type function parameters.
-
Associative array constructors.
-
Conversion and set operations on collection types.
Built-in packages
Version 2.0 provides the following Oracle-compatible built-in packages:
| Package | Description |
|---|---|
DBMS_AQ |
Message queue enqueue and dequeue operations |
DBMS_AQADM |
Message queue configuration and management |
DBMS_ALERT |
Registering, sending, and receiving alerts |
DBMS_APPLICATION_INFO |
Recording module and transaction names for performance tracking |
DBMS_CRYPTO |
Encryption and decryption with AES, DES, hashing, and message digest functions |
DBMS_DDL |
DDL-related operations |
DBMS_JOB |
Creating and managing scheduled tasks |
DBMS_LOB |
Access and operations on large objects (BLOB and CLOB) |
DBMS_LOCK |
Built-in SLEEP function to pause the current session |
DBMS_METADATA |
Retrieving metadata for database objects |
DBMS_MVIEW |
REFRESH without requiring dependent objects |
DBMS_OUTPUT |
Sending messages from stored procedures, packages, or triggers |
DBMS_XMLGEN |
XML data conversion |
DBMS_XMLPARSER |
Parsing XML documents to generate Document objects |
DBMS_PIPE |
Pipe communication between sessions in the same instance |
DBMS_RANDOM |
Random number generation functions |
DBMS_REDACT |
Data masking for queries by low-privilege users or applications |
DBMS_RLS |
Virtual Private Database (VPD) policies on database objects |
DBMS_SESSION |
Session, user, and environment information from PL/SQL |
DBMS_SPACE |
Space management operations |
DBMS_SQL |
Dynamic SQL for DML and DDL statements, anonymous blocks, stored procedures, and functions |
DBMS_TRANSACTION |
Transaction operations |
DBMS_UTILITY |
Utility subroutines and package dependency retrieval |
DBMS_XMLDOM |
DOM access for XML documents |
UTL_ENCODE |
Data encoding and decoding |
UTL_I18N |
Globalization support via ESCAPE_REFERENCE and UNESCAPE_REFERENCE |
UTL_MATCH |
String pattern matching |
UTL_HTTP |
HTTP interaction |
UTL_RAW |
RAW data manipulation |
UTL_TCP |
TCP communication |
UTL_URL |
URL character encoding and decoding |
System view compatibility
Version 2.0 adds support for the following Oracle-compatible views:
-
ALL_PART_KEY_COLUMNS,USER_PART_KEY_COLUMNS,DBA_PART_KEY_COLUMNS -
DBA_ROLE_PRIVS,USER_ROLE_PRIVS -
DBA_COL_COMMENTSfor viewing and managing column comments -
NLS parameter views for internationalization configuration
-
DBA_TAB_COLUMNSwith all parameters -
SESSION_ROLEfor session role management -
USER_TAB_PARTITIONSwith theHIGH_VALUEfield -
DBA_OBJECTSwith theCREATEDfield for object creation timestamps
Other features
Syntax compatibility differences
The following features from version 1.0 are not supported in version 2.0.
Review these limitations before migrating. Workloads that depend on any of the following behaviors will require code changes.
| Category | Limitation |
|---|---|
| Data types | ABSTIME type is not supported. |
| DDL syntax | CASCADE after DROP USER is not supported. GRANT EXEMPT ACCESS POLICY TO USERNAME is not supported. SHOW ROLE is not supported. NOLOGGING after CREATE INDEX is not supported. |
| Views and partitioned tables | Some Oracle-compatible view definitions do not include a SCHEMA_NAME column. A partitioned table's parent table must have at least one child partition. Null values cannot be inserted into non-DEFAULT partitions. ATTACH is not supported on HASH partitions. For LIST partitioned tables with a default partition, ADD PARTITION is not allowed. |
| Functions, stored procedures, and triggers | Functions and stored procedures cannot share the same name. Functions and stored procedures with subqueries as parameters are not supported. The fourth parameter of REGEXP_REPLACE cannot be 'n'. DECODE with only two input parameters is not supported. COLLATE modifier on character parameters is not supported. GET_RAW_PAGE with double-quoted first parameter is not supported. ROWNUM as a function parameter is not supported. If a stored procedure has no ANYELEMENT input, ANYELEMENT output is not allowed. If a parameter in an SQL function has a default value, all subsequent parameters must also have default values. Trigger names must be exactly 54 characters in length. |
| Transactions | Autonomous transactions that include write operations must be explicitly committed or rolled back. |
| SQL queries | The following optimizer hints are not supported: CHOOSE, FIRST_ROWS, FIRST_ROWS_10, FIRST_ROWS_100, FIRST_ROWS_1000. Synonyms cannot be used in a subquery to reference objects in a parent query. INSERT ALL INTO xxx ... SELECT xxx without VALUES xxx is not supported. Comparing the DUMMY column in the DUAL table with numeric types is not supported. '!!a' factorial notation is not supported. Non-immutable functions cannot call other functions. Setting ICU_SHOR_FORM to 'AN_CX_EX_LROOT_NO_S3' when creating a COLLATION is not supported. BIT type cannot assign default values to BOOL type. Columns cannot assign default values to other columns. |
| Packages | Package variables cannot be used in SQL statements. DBMS_SQL.TO_REFCURSOR and DBMS_SQL.TO_CURSOR_NUMBER are not supported. SELECT INTO in DBMS_SQL is not supported. DEFINE_COLUMN for non-SELECT statements is not supported. DBMS_SQL.NATIVE constant assignment is not supported. Pure numbers as table names in DBMS_UTILITY are not supported. NULL as input for GET_HASH_VALUE is not supported. 0 as input for RANDOMBYTES in DBMS_CRYPTO is not supported. Starting position exceeding the RAW total length in UTL_RAW.SUBSTR is not supported. Negative numbers for the TIMEOUT parameter in DBMS_PIPE.SEND_MESSAGE are not supported. DBMS_RLS policy functions cannot return NULL. Negative numbers in DBMS_LOB.INSTR are not supported. |
| PL/SQL and collection types | SQLCODE and SQLERRM cannot be called outside exception handlers. Dynamic SQL cannot be bound to strongly typed cursors. DDL operations in parameterized dynamic SQL are not supported. STRING or LONG types cannot be used as index types for associative arrays. Non-null properties for collection types cannot be declared globally. |