Activating ClickHouse Data for AI-Powered Personalization with Shaped

ClickHouse is unmatched when it comes to high-performance analytics at scale, trusted for powering fast, flexible querying across billions of events. But what if the same data fueling dashboards could also drive real-time personalization? That’s where Shaped comes in. By connecting ClickHouse to Shaped, teams can transform rich historical interaction data into intelligent recommendations, personalized search, and predictive insights, without straining their analytics stack. This post explores how ClickHouse and Shaped together unlock the full potential of your event data.

Leveraging Your High-Performance Analytics Database for Real-Time Relevance

ClickHouse has gained immense popularity as an open-source, column-oriented database management system renowned for its exceptional speed in processing large volumes of analytical queries (OLAP). Organizations often leverage ClickHouse to store and analyze massive event streams, logs, time-series data, and user interaction histories due to its raw performance. While invaluable for analytics, the next step is often activating this rich data to drive intelligent, personalized experiences in real-time.

How do you transform the billions of user events stored efficiently in ClickHouse into accurate predictions of what a user will engage with next? How do you personalize search results or recommendation carousels based on patterns hidden within that vast dataset without overloading your ClickHouse cluster with complex, per-user queries? This is where Shaped's dedicated ClickHouse connector provides a powerful and efficient solution.

Shaped is an AI-native relevance platform designed to securely connect to data sources like ClickHouse, ingest relevant data, train state-of-the-art machine learning models, and serve personalized search rankings and recommendations via simple APIs. This post explains the benefits of using your ClickHouse data with Shaped and guides you through the straightforward integration process.

Why Connect ClickHouse to Shaped? From Fast Analytics to Smart Actions

Connecting your ClickHouse database to Shaped allows you to bridge the gap between high-speed analytics and sophisticated AI-driven personalization, enabling powerful use cases:

  • Deeply Personalized Recommendations: Utilize the extensive historical interaction data often stored in ClickHouse:
    • Long-Term Behavior Modeling: Train models on vast event streams in ClickHouse to understand user preferences over extended periods.
    • Leverage Detailed Event Properties: Incorporate rich attributes stored alongside events in ClickHouse (e.g., device type, location, specific interaction details) into personalization models.
    • Fast-Updating Catalog Awareness: If item metadata is stored or updated frequently in ClickHouse, Shaped can sync it to ensure recommendations reflect the latest catalog state.
    • "Similar Item" Discovery: Identify related items based on behavioral patterns learned from large-scale ClickHouse interaction logs.
  • Enhanced Search Personalization: Improve search relevance using insights derived from ClickHouse data:
    • Behaviorally-Informed Ranking: Train search ranking models using historical engagement metrics (clicks, conversions) stored in ClickHouse.
    • Personalize Based on Historical Activity: Tailor search results based on a user's long-term interaction patterns captured in ClickHouse event tables.
  • Advanced Analytics & Model Insights: Apply sophisticated ML to your ClickHouse data for deeper understanding:
    • Complex Journey Analysis: Model intricate user paths and predict future actions based on patterns learned from large ClickHouse datasets.
    • User/Item Embedding Generation: Create powerful vector representations from ClickHouse data for cohort analysis, anomaly detection, or downstream ML tasks.
    • Offline Performance Simulation: Use historical data slices from ClickHouse to evaluate potential personalization strategies.
  • Efficient Data Synchronization: Shaped's connector directly syncs data from ClickHouse based on a replication key, avoiding the need to build and maintain complex ETL pipelines specifically for personalization ML.
  • Optimized Resource Usage: Offload the computationally intensive task of training and serving complex ML models from your ClickHouse cluster to Shaped's specialized infrastructure.

How it Works: The ClickHouse Dataset Connector

Shaped connects to your ClickHouse instance using dedicated read-only credentials you provide. You configure which table and columns Shaped should sync. Shaped then periodically queries your ClickHouse table, using a specified replication_key (like a timestamp or an auto-incrementing ID) to efficiently fetch only new or updated rows after the initial data load. This keeps the data in Shaped fresh without requiring constant streaming or heavy querying of your ClickHouse database.

Connecting ClickHouse to Shaped

The setup involves creating a read-only user in ClickHouse and then configuring the dataset connection within Shaped.

Step 1: Prepare ClickHouse - Create a Read-Only User

For security best practices, Shaped requires a dedicated ClickHouse user with only the necessary read permissions.

  1. Connect to your ClickHouse instance using a client or CLI with administrative privileges.
  1. Execute the following SQL commands, replacing database_name.* or database_name.table_name with the actual database and table(s) Shaped needs access to, and choosing a strong password:

-- 1. Create a new user with a secure password

create_read_only_user.sql

1 -- 1. Create a new user with a secure password
2 CREATE USER shaped_read_only IDENTIFIED BY 'YOUR_SECURE_PASSWORD_HERE!';
3 
4 -- 2. Grant SELECT privileges on the specific database(s) and table(s)
5 
6 -- Option A: Grant access to all tables in a database
7 GRANT SELECT ON your_database_name.* TO shaped_read_only;
8 
9 -- Option B: Grant access only to specific tables (Recommended for stricter security)
10 -- GRANT SELECT ON your_database_name.your_events_table TO shaped_read_only;
11 -- GRANT SELECT ON your_database_name.your_items_table TO shaped_read_only;
    
  1. Securely store the username (shaped_read_only in this example) and the password you created. You will need them for the Shaped configuration.

Step 2: Configure the Shaped Dataset (YAML)

Define the connection details and data synchronization parameters in a YAML configuration file.

Create a YAML file (e.g., clickhouse_dataset.yaml):

clickhouse_dataset.yaml

1 name: your_clickhouse_dataset_name # Choose a descriptive name
2 
3 # --- Required Fields ---
4 schema_type: CLICKHOUSE # Specifies the connector type
5 table: your_table_name # The specific table in ClickHouse to sync from
6 user: shaped_read_only # The read-only username created in Step 1
7 password: YOUR_SECURE_PASSWORD_HERE! # The password for the read-only user
8 host: your.clickhouse.host.com # Hostname or IP address of your ClickHouse server
9 port: 9440 # Port ClickHouse is listening on (e.g., 8443 for HTTPS, 8123 for HTTP, 9440 for secure native)
10 
11 # The column Shaped uses to track changes for incremental syncs.
12 # MUST be a column that reliably increases over time (e.g., event timestamp,
13 # auto-incrementing ID, updated_at timestamp).
14 replication_key: event_timestamp # Or created_at, id, updated_at etc.
15 
16 # --- Optional Fields ---
17 database: your_database_name # The database containing the table (if not default)
18 
19 # List specific columns to sync. If omitted, Shaped syncs all columns.
20 # columns: ["user_id", "item_id", "timestamp", "event_type", "some_property"]
21 # Columns uniquely identifying a row (for deduplication based on replication_key).
22 # unique_keys: ["event_id"]
23 # Schedule for periodic syncs (Cron format, e.g., "@hourly", "@daily", "*/15 * * * *").
24 # Defaults to "@hourly" if omitted.
25 # schedule_interval: "@hourly"
26 # description: "User interaction events from ClickHouse"
    

Key Configuration Points:

  • Credentials:
  • Ensure user and password match the read-only user created in ClickHouse.
  • host & port: Provide the correct connection details for your ClickHouse instance.
  • replication_key: This is critical for efficient syncing after the initial load. Choose a column that guarantees new/updated records will have a greater value than previous records (timestamps or increasing IDs work well).
  • columns (Optional): Selecting only necessary columns improves sync efficiency and reduces data transfer.

Step 3: Create the Dataset in Shaped

Use the Shaped CLI to create the dataset from your YAML configuration file:

create_clickhouse_dataset.sh

1 shaped create-dataset --file clickhouse_dataset.yaml
    

Shaped will validate the configuration and credentials, then attempt to connect to your ClickHouse database. You can monitor the initial sync progress and ongoing status via the Shaped Dashboard or CLI (shaped view-dataset --dataset-name your_clickhouse_dataset_name).

What Happens Next? Syncing, Training, Personalizing

Once the connection is active:

  1. Initial Sync:
  2. Shaped performs a full sync of the specified table based on your configuration (respecting columns, etc.).
  3. Incremental Syncs:
  4. Based on the schedule_interval (defaulting to hourly), Shaped queries ClickHouse for rows where the replication_key is greater than the maximum value seen in the previous sync, efficiently fetching only new data.
  5. Model Training: Shaped uses the synced data to train its advanced AI models for personalization. Training can be scheduled within Shaped.
  6. API Serving: After models are trained, Shaped's APIs are ready to serve personalized search rankings, recommendations, or analytics embeddings derived from your ClickHouse data.
  7. Continuous Updates: Scheduled syncs and model retraining keep the personalization fresh based on the latest data available in your ClickHouse instance.

Conclusion: Bridge High-Speed Analytics with AI-Powered Relevance

Your ClickHouse database is a powerhouse for storing and querying vast amounts of data at speed. By connecting it to Shaped, you can effectively leverage this valuable asset to fuel state-of-the-art AI personalization without overburdening your ClickHouse cluster or investing heavily in building custom ML infrastructure. Shaped provides the specialized AI layer, enabling you to transform ClickHouse data into dynamic, engaging user experiences efficiently.

Ready to activate your ClickHouse data for intelligent recommendations and search?

Request a demo of Shaped today to see it in action with your specific use case. Or, start exploring immediately with our free trial sandbox.

Get up and running with one engineer in one sprint

Guaranteed lift within your first 30 days or your money back

100M+
Users and items
1000+
Queries per second
1B+
Requests

Related Posts

Tullie Murrell
 | 
September 20, 2022

Day 2 of #RecSys2022: Our favorite 5 papers and talks

Tullie Murrell
 | 
May 27, 2025

The Power of Deep Learning for Hyper-Personalized Recommendations

Tullie Murrell
 | 
May 29, 2025

Shaped vs. Building Your Own: The AI Relevance Dilemma – Platform or DIY Stack?