8 Major PostgreSQL Compatibility Enhancements in MogDB 5.0

Welcome to follow our public account, where we continuously publish in-depth articles on PostgreSQL, openGauss/MogDB, and other PG-related databases.

1. Sequences Can Be Modified Through DDL Statements

MogDB 5.0 supports modifying sequence properties using the ALTER SEQUENCE command:

8 Major PostgreSQL Compatibility Enhancements in MogDB 5.0

2. Cursors Support Reverse Retrieval

openGauss inherits from pgxc, where the distributed pgxc disables the SCROLL attribute for cursors. In MogDB 5.0, in Amode or PG mode, you can specify the SCROLL attribute for cursors to enable reverse retrieval of data rows (i.e., backward retrieval).

8 Major PostgreSQL Compatibility Enhancements in MogDB 5.0

3. Logical Export Supports Parallelism Between Tables

MogDB 5.0 supports parallel import and export tasks between tables using gs_dump -j and gs_restore -j, with the following syntax:

gs_dump -f /tmp/backupdir -Fd -j 4 postgres

gs_restore -d res_db -Fd -j 4 /tmp/backupdir

For single table parallelization, for example, exporting a large non-partitioned table, you can first use the pg_export_snapshot() function to obtain the transaction snapshot ID, and then use multiple clients to perform parallel export under the same transaction snapshot at the RR isolation level.

4. Table-Level Logged/Unlogged Attribute Supports Online Switching

By default, tables with the logged attribute have WAL write protection, which eliminates the risk of data loss. However, unlogged tables do not record WAL and offer better performance. Users can flexibly choose and switch between them for different scenarios.

MogDB 5.0 supports online switching of table’s logged/unlogged attributes in PG/A compatibility mode and is compatible with both usage styles:

1. PG Style Usage:

CREATE TABLE tab1 (...);
ALTER TABLE tab1 SET UNLOGGED;
ALTER TABLE tab1 SET LOGGED;

2. Oracle Style Usage:

CREATE TABLE tab1 (...);
ALTER TABLE tab1 LOGGING;
ALTER TABLE tab1 NOLOGGING;

5. WITH Statement Compatible with More Scenarios While Remaining Not Materialized

The WITH statement, also known as Common Table Expressions (CTEs), can break down large complex queries into smaller fragments for easier readability and understanding. Additionally, using the WITH statement can

Leave a Comment