ApsaraDB RDS for PostgreSQL primary instances support hybrid transactional and analytical processing (HTAP) acceleration. This feature improves analytical query performance by adding a DuckDB-based columnar storage engine. This topic describes how to enable HTAP acceleration for a primary instance and configure columnar storage.
Applicability
The primary ApsaraDB RDS for PostgreSQL instance must be of the Basic or High-availability series.
HTAP acceleration is not supported for Cluster Edition instances.
Usage notes
Before you enable HTAP acceleration, note the following:
Disk space — After you trigger row-to-column conversion, the system adds a columnar store. Monitor your instance's disk space usage to prevent it from running out of disk space.
Transient disconnection — A transient disconnection occurs while HTAP acceleration is being enabled for the primary instance. Perform this operation during off-peak hours or ensure that your application has an automatic reconnection mechanism.
Read-only instance restriction — After you enable HTAP acceleration for a primary instance, you cannot add DuckDB-based analytical read-only instances to it. You also cannot enable HTAP acceleration for a primary instance that already has a DuckDB-based analytical read-only instance attached.
Database recovery — If you recover a database on a primary instance with HTAP acceleration enabled, the new instance created from the recovery does not automatically inherit the HTAP feature. You must enable the feature again for the new instance.
Step 1: Enable HTAP acceleration
In this step, you enable HTAP acceleration through the ApsaraDB RDS console.
Log on to the ApsaraDB RDS console.
In the left-side navigation pane, click Instances. Then, in the top navigation bar, select the region where the instance is located.
Find the target instance and click its instance ID.
Go to the HTAP acceleration page in one of the following ways:
Method 1: At the top of the instance details page, click HTAP Acceleration.
Method 2: In the Configuration Information section of the instance details page, locate the HTAP Acceleration configuration item and click Settings.
In the Prerequisite Check dialog box, review the prerequisite check results.
If all checks pass, click OK to start enabling HTAP acceleration.
If a check fails, handle the issue as prompted:
Items that can be automatically fixed: For items such as Minor Version and Parameter Settings, click OK. The system automatically completes the upgrade or configuration.
Items that must be manually fixed: For items such as Major Version or Instance Resources, follow the instructions in the referenced documents. Then, enable HTAP acceleration again.
Major engine version upgrade: See Upgrade a major engine version.
Change configuration: See Change instance specifications.
The prerequisite check dialog box displays the following information at the top: Enabling HTAP adds columnar storage. Monitor the disk usage of the instance. A transient disconnection occurs during the process. If the parameter check fails, the system automatically modifies the following parameters:
Parameter Change shared_preload_librariesrds_duckdbis added.wal_levelChanged from replicatological.hot_standby_feedbackChanged from offtoon.max_replication_slotsChanged from 16to1024.max_worker_processesChanged from 8to1024.max_wal_sendersChanged from 64to1024.Wait for the feature to be enabled. After the feature is enabled, the status of HTAP Acceleration in the Configuration Information section changes to Enabled.
Step 2: Configure columnar storage
After you enable HTAP acceleration for the primary instance, configure columnar storage for the tables that you want to use for analytical queries.
Use DMS or another database client to connect to the destination database with a privileged account.
Run the following command to create the
rds_duckdbextension:CREATE EXTENSION IF NOT EXISTS rds_duckdb;Run the following command to convert a specified table to columnar storage:
Convert a single table:
SELECT rds_duckdb.create_duckdb_table('table_name');Replace
table_namewith the name of the table that you want to convert. To convert multiple tables, run this command multiple times.Convert multiple tables in a batch:
SELECT rds_duckdb.create_duckdb_tables('{a,b,c...}');Use
create_duckdb_tables(plural form) to batch transform multiple tables. Enclose the table names in curly braces and separate them with commas.