Skip to main content
Modern AI and ML workloads operate with sizable datasets. Managed Service for PostgreSQL allows you to apply its flexibility and dataset management capabilities to enhance the performance of your projects in Nebius AI Cloud. This guide will get you started with Managed Service for PostgreSQL. You will:
  • Install and configure CLIs to work with Managed Service for PostgreSQL
  • Create your first cluster
  • Connect to the cluster
  • Perform basic operations with a PostgreSQL database
If you want to move data from an external PostgreSQL cluster to a Managed PostgreSQL cluster, use migration or replication.

Prepare your environment

Before moving on with this guide, make sure you have the postgresql package installed. You will need it to connect to your cluster and test a database within it.

Install postgresql package

  1. Ensure you have Homebrew installed.
  2. Run the command to install PostgreSQL CLI:
    brew install libpq
    

(Optional) Install the Nebius AI Cloud CLI or provider for Terraform

If you want to manage clusters and other Nebius AI Cloud resources in the command line or using Terraform, install and configure one of these tools:

Create a cluster

  1. In the sidebar, go to https://mintcdn.com/nebius-ai-cloud/1Ha0sWR6e1mnIaHS/_assets/sidebar/storage.svg?fit=max&auto=format&n=1Ha0sWR6e1mnIaHS&q=85&s=0a2dad6b48aea10e85f6f3e2343aee26 Storage → PostgreSQL.
  2. Click https://mintcdn.com/nebius-ai-cloud/1Ha0sWR6e1mnIaHS/_assets/plus.svg?fit=max&auto=format&n=1Ha0sWR6e1mnIaHS&q=85&s=7c9efc69d65fc58db0eb73702fd81aa1 Create cluster.
  3. On the page that opens:
    1. Specify the Name for your cluster. Do not use spaces in cluster names.
    2. Write a short Description of your cluster. For example, .
    3. In the Username field, type the username.
    4. In the Password field, come up with a secure password. Such a password must contain at least:
      • 8 characters
      • One lowercase character
      • One uppercase character
      • One special character
    5. Keep all the other settings with their default values - they will be more than enough for the purposes of this guide.
    6. Click Create cluster.
On the Managed Service for PostgreSQL® page, you will see your cluster with the Provisioning status.Please wait until its status changes to Running before trying to perform any operations on your new cluster.

Connect to your cluster

  1. Open your cluster’s page.
  2. Under the cluster name, click How to connect.
  3. Follow the instructions in the dialog window.
  4. To check the connection, list all the databases on your cluster with the command:
    \l
    
    You should see the following output:
                                    List of databases
        Name    |  Owner   | Encoding | Collate | Ctype |        Access privileges         
    ------------+----------+----------+---------+-------+----------------------------------
     postgres   | postgres | UTF8     | C       | C     | =Tc/postgres                    +
                |          |          |         |       | postgres=CTc/postgres           +
                |          |          |         |       | cnpg_pooler_pgbouncer=c/postgres
     template0  | postgres | UTF8     | C       | C     | =c/postgres                     +
                |          |          |         |       | postgres=CTc/postgres
     template1  | postgres | UTF8     | C       | C     | =c/postgres                     +
                |          |          |         |       | postgres=CTc/postgres
    

Perform operations with a test database

In this guide, we’ll use the dellstore2 dataset. It contains a fictional store database with products, orders, inventory and customer information.
  1. Download the dellstore2-normal-1.0.tar.gz file from the PostgreSQL website.
  2. Unarchive the file into a folder.
  3. From the folder to which you unarchived the file, connect to your Managed Service for PostgreSQL cluster with the Nebius AI Cloud CLI and create a database on your cluster:
    CREATE DATABASE dellstore;
    
  4. Upload the dataset from the file onto your cluster:
    \i dellstore2-normal-1.0.sql;
    
  5. Check if the objects were created successfully:
    \d
    
    You should see the following output:
                        List of relations
     Schema |           Name           |   Type   |      Owner  
    --------+--------------------------+----------+-----------------
     public | categories               | table    | <your_username>
     public | categories_category_seq  | sequence | <your_username>
     public | cust_hist                | table    | <your_username>
     public | customers                | table    | <your_username>
     public | customers_customerid_seq | sequence | <your_username>
     public | inventory                | table    | <your_username>
     public | items                    | table    | <your_username>
     public | orderlines               | table    | <your_username>
     public | orders                   | table    | <your_username>
     public | orders_orderid_seq       | sequence | <your_username>
     public | products                 | table    | <your_username>
     public | products_prod_id_seq     | sequence | <your_username>
     public | reorder                  | table    | <your_username>
    (13 rows)
    
  6. Write a row into the products table:
    INSERT INTO products(
        prod_id,
        category,
        title,
        actor,
        price,
        special,
        common_prod_id
    )
    VALUES (
        10001,
        42,
        'FUTURE INTELLIGENCE',
        'FORD PREFECT',
        42.42,
        0,
        1978
    );
    
  7. Query the database to see that your row was written correctly:
    SELECT * FROM products WHERE prod_id = 10001;
    
    You should get the following output:
     prod_id | category |        title        |    actor     | price | special | common_prod_id 
    ---------+----------+---------------------+--------------+-------+---------+----------------
       10001 |       42 | FUTURE INTELLIGENCE | FORD PREFECT | 42.42 |       0 |           1978
    (1 row)
    

Postgres, PostgreSQL and the Slonik Logo are trademarks or registered trademarks of the PostgreSQL Community Association of Canada, and used with their permission.