AnalyticDB for PostgreSQL is a cloud-native Massively Parallel Processing (MPP) data warehouse designed for online analytical processing (OLAP) of large-scale data. AnalyticDB for PostgreSQL supports two instance resource types: Storage Elastic Mode and Serverless Pro. The Serverless Pro mode uses a cloud-native architecture to decouple compute and storage resources, enabling independent scaling of each. This topic describes how to create a Serverless Pro instance and query its data.
Preparations
An Alibaba Cloud account is required. If you do not have an account, you can register one on the Alibaba Cloud official website.
Authorize a service-linked role. The first time you use AnalyticDB for PostgreSQL, you must authorize the creation of a service-linked role in the console. To do this, perform the following steps:
- Log on to the AnalyticDB for PostgreSQL console.
In the upper-right corner of the page, click Create Instance.
In the Create Service Linked Role dialog box that appears, click OK.
Pricing
Creating an instance incurs fees for compute and storage resources. For more information, see Pricing.
Procedure
Create an instance
- Log on to the AnalyticDB for PostgreSQL console.
In the upper-right corner of the page, click Create Instance to go to the purchase page.
On the purchase page, configure the core parameters. Keep the default values for other parameters. For more information about the parameters, see Create an instance.
Configuration Item
Description
Example for this tutorial
Product Type
Subscription: This is a subscription billing method. You pay upfront when you create the instance. It is suitable for long-term use and is more cost-effective than pay-as-you-go. The longer the subscription duration, the higher the discount.
Pay-as-you-go: This is a pay-as-you-go billing method. You are charged on an hourly basis. It is suitable for short-term use. You can release the instance immediately after use to save costs.
Pay-as-you-go
Region and Zone
The geographic location of the instance.
The region cannot be changed after purchase. Create the instance in the same region as the ECS instance that you want to connect to. This allows for service interconnection over a private network.
China (Hangzhou): Zone J
Instance Resource Type
Storage Elastic Mode: Supports independent disk scale-out and online smooth scale-out.
Serverless Pro: Specify the required compute resources. You do not need to reserve storage resources.
Serverless Pro
Master Resources
Select the Master resource specifications. Select the specifications based on the formula:
Master CU = Number of CPU cores of a single segment.If you need more Master resources, increase the specifications after the instance is created. For more information, see Master resource management.
8 CU (Free)
Reserved Compute Resources
The number of CUs for compute nodes. The minimum is 16 CUs (16 Segments).
16
Serverless Cache Space
The total size of the cloud disks attached to the compute nodes. Set the minimum size to 800 GB. If you need more than 800 GB, adjust the size based on the amount of hot data. For example, set it to 30% of the total data volume.
NoteThis is not the cache space for a single compute node.
800
Virtual Private Cloud
Select the ID of the VPC.
To interconnect with an ECS instance in the same region over a private network, select the same VPC as the ECS instance. You can select an existing VPC or create a VPC and vSwitch as prompted.
vpc-xxxx
vSwitch
Select a vSwitch in the VPC. If no vSwitches are available, no vSwitch resources are available in the current zone. You can switch to another zone or create a vSwitch in the current zone as prompted.
vsw-xxxx
Click Buy Now , confirm the order information, and click Activate Now .
After the payment is complete, click Management Console to return to the instance list and view the new instance.
NoteThe initialization of an AnalyticDB for PostgreSQL instance takes some time. You can perform subsequent operations only after the instance status changes to Running .
(Optional) Configure a whitelist
You can skip this step if you access the database only using Data Management (DMS). If you want to access the database from a local integrated development environment (IDE), you must configure an IP address whitelist. For more information about how to obtain the client IP address, see Preparations.
In the instance list, find the instance that you created and click its ID to open the instance details page.
In the navigation pane on the left, click Security Controls.
Click Create Whitelist and configure the following parameters:
Configuration
Description
Whitelist Name
The name of the new whitelist group. The name must meet the following requirements:
Consist of lowercase letters, digits, and underscores (_).
Start with a lowercase letter and end with a lowercase letter or a digit.
Be 2 to 32 characters in length.
IP Addresses
The IP addresses to add to the whitelist. Note the following:
Separate multiple IP addresses with commas (,). You can add up to 999 unique IP addresses.
The supported formats are specific IP addresses, such as 10.23.12.24, and CIDR blocks, such as 10.23.12.24/24. CIDR stands for Classless Inter-Domain Routing. The number after the slash (/) indicates the prefix length, which can be from 1 to 32.
If you set the prefix length to 0, such as 0.0.0.0/0 or 127.0.0.1/0, all IP addresses can access the instance. This poses a high security risk. Use this setting with caution.
The IP address 127.0.0.1 blocks access from all external IP addresses.
Click OK.
Create an initial account
AnalyticDB for PostgreSQL provides two types of users:
Privileged user: The initial account is a privileged user with the RDS_SUPERUSER role. This role grants all operational permissions on the database.
Regular user: By default, a regular user has no permissions. A privileged user, or another user with the GRANT permission, must explicitly grant permissions on database objects to the regular user. For more information about how to create a regular user, see Create and manage users.
In the navigation pane on the left, click Account Management.
Click Create Account. In the Create Account window, enter an account name, set a password, and then click OK.
Parameter
Description
Account
The name of the initial account.
Contain lowercase letters, digits, and underscores (_).
Must start with a lowercase letter and end with a lowercase letter or a digit.
Cannot start with gp.
Must be 2 to 16 characters in length.
New Password and Confirm Password
The password of the initial account.
Must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters.
Special characters include
! @ # $ % ^ & * ( ) _ + - =.Must be 8 to 32 characters in length.
ImportantFor security, change your password regularly and avoid reusing old ones.
Load a sample dataset
You can load a sample dataset for testing. The loading process takes about 6 to 8 minutes.
In the upper-right corner of the instance details page, choose .

In the Load Sample Dataset dialog box, click OK.
Connect to the database
This section describes how to connect to the database using DMS. For more information about how to connect to the database using other clients, see Client connections.
In the upper-right corner of the instance details page, click Log On to Database.
On the Log On to Instance page, enter the Database Account and Database Password, and click Logon.
Query data
In the navigation pane on the left of the DMS console, click the target instance. If you are in simple mode, you must first switch to the Database Instances tab. Then, check whether the
adb_sampledata_tpchdatabase exists.If the item does not appear, click the refresh button to the right of the target instance and check again.

Double-click the
publicschema under theadb_sampledata_tpchdatabase to open an SQL Console window. Then, run the following SQL statement to query data.SELECT count(*) FROM lineitem;The following result is returned:
+-----------+ | count(*) | +-----------+ |59986052 | +-----------+
References
Instance scaling: You can manage Master resources and scale reserved resources.