Enable DuckDB for a primary instance

更新时间:
复制 MD 格式

You can enable DuckDB acceleration for a primary ApsaraDB RDS for PostgreSQL instance to improve analytical query performance with a columnar storage engine. This topic describes how to enable DuckDB acceleration for a primary ApsaraDB RDS for PostgreSQL instance.

Prerequisites

The instance must meet the following requirements before you enable DuckDB acceleration for a primary ApsaraDB RDS for PostgreSQL instance:

  • instance state: Running.

  • major version: PostgreSQL 13.0 or later.

  • Edition: Basic Edition or High-availability Edition.

    Note

    Cluster Edition instances do not support DuckDB acceleration.

  • billing method: subscription or pay-as-you-go.

  • minor version: 20260130 or later.

  • instance parameters: The following parameters are configured as specified.

    The wal_level parameter is set to logical, shared_preload_libraries includes rds_duckdb, max_replication_slots is set to a value greater than or equal to 1024, max_worker_processes is set to a value greater than or equal to 1024, and max_wal_senders is set to a value greater than or equal to 1024.

  • The instance is not a disaster recovery instance.

Important notes

  • After you convert row-based tables to columnar storage, the system creates additional columnar data. Monitor your disk usage to prevent storage space from running out.

  • Enabling DuckDB acceleration for the primary instance causes a transient disconnection. We recommend that you perform this operation during off-peak hours or ensure your application has an automatic reconnection mechanism.

  • After DuckDB acceleration is enabled for a primary instance, you cannot add DuckDB read-only instances. Likewise, you cannot enable DuckDB acceleration for a primary instance with DuckDB read-only instances.

  • If you perform a database recovery operation on a primary instance with DuckDB acceleration enabled, the new instance created by the recovery does not automatically inherit DuckDB acceleration. You must enable it again manually.

Procedure

Step 1: Enable DuckDB acceleration

  1. Log on to the ApsaraDB RDS console.

  2. In the navigation pane on the left, click Instances. In the top navigation bar, select the region where your instance is located.

  3. Find the target instance and click its instance ID.

  4. Navigate to the DuckDB acceleration page by using one of the following methods:

    • Method 1: At the top of the Instance Details page, click Enable HTAP Acceleration.

    • Method 2: In the Basic Information section of the Instance Details page, find HTAP Acceleration and click Settings.

  5. In the HTAP Acceleration Pre-check dialog box, review the prerequisite check results.

    • If all checks pass, click confirm to start enabling DuckDB acceleration.

    • If any checks fail, resolve the issues by following the instructions below:

      • Auto-fixable items: For items that can be fixed automatically, such as Minor Version and Parameter Settings, click confirm. The system automatically performs the required upgrades or configurations.

      • Manual-fix items: For items that require manual intervention, such as Major Version or Instance Resources, refer to the following documentation to perform the required operations. Then, try to enable DuckDB acceleration again.

      image

  6. Wait for the process to complete. After DuckDB acceleration is enabled, the HTAP Acceleration status changes to Enabled in the Basic Information section of the Instance Details page.image

Step 2: Configure columnar storage

After you enable DuckDB acceleration for the primary instance, configure columnar storage for the tables that you want to use for analytical queries by following these steps:

  1. Use Data Management Service (DMS) or another database client tool to connect to the target database with a privileged account.

  2. Run the following statement to create the rds_duckdb extension:

    CREATE EXTENSION IF NOT EXISTS rds_duckdb;
  3. Run the following statement to convert specified tables to columnar storage:

    • Convert a single table:

      SELECT rds_duckdb.create_duckdb_table('your_table_name');
      Note

      Replace TableName with the actual table name. If you need to convert multiple tables, run this command multiple times.

    • Convert multiple tables in a batch:

      SELECT rds_duckdb.create_duckdb_tables('{table_a,table_b,table_c}');
      Note

      Use create_duckdb_tables (the plural form) to convert multiple tables in a batch. The table names must be enclosed in curly braces and separated by commas.