Getting started

Understand the financial benefits of CAST AI database optimization.

This guide will walk you through the initial steps to set up and start using Cast AI DB Optimizer (DBO) for your database. Following these instructions, you can implement DBO and optimize your database performance quickly.

AWS RDS

(Optional) Phase 1: Estimation

Follow the steps below to connect your database cloud provider and generate a cost savings and performance benefits estimation report.

Step 1: Connect your AWS RDS account

  1. Log in to the Cast AI console.
  2. Navigate to the Database optimization section.
  3. Click on Run estimation to begin connecting your AWS RDS account.
  1. Copy the provided script and run it in your AWS RDS cloud shell or terminal.

Step 2: Review instances and potential savings

Once connected, you'll be presented with the Instances dashboard, which will highlight the metrics from the Estimation phase. Analyze the provided insights to see the potential cost savings and performance benefits that DBO can deliver to your database instances.

This dashboard provides an overview of connected database instances and their optimization potential within the Cast AI platform. To delve deeper into the cost savings report, see Performance estimation & cost savings

Time Range Selection for Analysis

After connecting your database instance, you can analyze its performance across different time periods using the time range selector in the top-right corner of the dashboard. This feature lets you view metrics from the last hour up to the last 7 days or select a custom date range.

Learn more in the Analyzing Database Performance guide.

Phase 2: Cache deployment

The next phase of leveraging Cast AI's DBO is moving beyond the reporting and into Phase 2, where you can deploy the cache and connect your applications.

Step 1: Deploy cache

Once your database instance is connected, you will be able to deploy the necessary dbo-cache component. The aforementioned component encompasses two containers:

  • Proxy: Intercepts database queries and routes them appropriately.
  • Query Processor: Manages the caching logic and data storage.

To begin the cache deployment, follow these steps:

  1. Select an instance from the list.
  1. Click on Deploy Cache to initiate the process of deploying the cache to your chosen instance. The cache is instance-wide. Therefore, it will work for all logical databases hosted on an instance.

Alternatively, deploy the cache by clicking on the three dots next to an instance and selecting Deploy Cache from the drop-down:

  1. Copy the provided script and run it in the cloud shell or terminal of your Kubernetes cluster to deploy the cache components.

Step 2: Update your application's connection string

To start using DBO, you must update your application's database connection string to route it to the proxy. Here's a general format:

  • [dbo_proxy_host]: The hostname or IP of the DBO Proxy (provided in the Cast AI console)
  • [dbo_port]: The port for your database type (e.g., 5432 for PostgreSQL)
  • [cache_id]: The unique identifier for your cache (found in the Cast AI console):

Example for PostgreSQL:

postgresql://myuser:[email protected]:5432/mydb?application_name=cache-123456

Step 3: Verify Connection

To ensure DBO is working correctly:

  1. Run a few queries through your application
  2. Check the DBO dashboard in the Cast AI console
  3. You should see query statistics and cache performance metrics

Manual Postgres DB

Connecting a PostgreSQL database manually

You can connect any PostgreSQL database to Cast AI DBO, regardless of where it's hosted.

Step 1: Add your PostgreSQL instance

  1. From the DBO dashboard, click "Add Account":

  2. Select "Manual (Postgres)" as your provider:

  3. Enter your database details:

  • Server name: A descriptive name to identify this database instance in the Cast AI console. Choose something meaningful that helps you recognize the database (e.g., "production-users-db" or "staging-analytics").

  • Host: The hostname or IP address where your PostgreSQL instance is running. This could be:

    • A cloud provider endpoint (e.g., your-db.123456.region.rds.amazonaws.com)
    • An internal hostname in your infrastructure
    • An IP address (e.g., 10.0.0.1)
  • Port: The TCP port number where PostgreSQL is accepting connections. The default PostgreSQL port is 5432, but your setup might use a different port.

  • Database name(s): The logical database names within your PostgreSQL instance that you want to optimize. You can add multiple databases that exist on the same instance. Enter each database name exactly as it appears in PostgreSQL.

📘

Note

Make sure you have the correct permissions to access these databases with the credentials you'll provide.

📘

Note

While performance insights are currently only available for AWS RDS instances, caching capabilities are available for all PostgreSQL deployments.

Step 2: Deploy the cache

Once your database instance is added, you can deploy the proxy cache. You can do this immediately after adding the instance or at a later time of your choosing.

Immediately

Copy and run the provided script in your environment's terminal to deploy the cache components:

Later

If you choose to deploy the cache later, skip the deployment modal when prompted. Once ready, do one of the following to get the installation script again:

  1. Click on the symbol next to the instance for which you want to deploy the cache and choose "Deploy cache" to trigger the modal with the deployment script:

  2. Alternatively, click on an instance, and you'll be presented with a banner that can trigger the script modal for you:

Update your application connection string

After cache deployment, you must replace the application connection string to route to the DBO cache instead of directly to your logical database. To do so, perform the following steps:

  1. Select the desired logical database within your connected instance

  2. Click on "View configuration" to open a drawer with database settings:

  3. Copy the new connection string provided in the drawer

  4. Update your application's database connection string to route through the cache

  5. Verify the connection is working by checking the Instances dashboard for query metrics, which should start populating within minutes.

For detailed configuration options and advanced settings, see Connecting client applications.