Best Practices for a VeloDB Cloud POC
Use a proof of concept (POC) to decide whether VeloDB Cloud meets the technical and operational requirements of your workload. Choose a workflow that matters to that decision, such as a dashboard that reads orders while new transactions arrive. Agree with its owner on what must improve, how you will measure it, and what result would justify moving to production. Use the same data and queries to measure the current system and VeloDB Cloud.
Prepare the POC
Define the scope and success criteria
Start with a business question. For an orders dashboard, how quickly must users see an order change, and how long can they wait for the dashboard during peak traffic? Agree on the test window, the people who can provide the data and review the results, and which workflows you can defer.
Copy the table into your test plan. Replace the example targets with your own, measure the current system in the Baseline column, and fill in the last column as you test.
| Business question | Test | Example acceptance target | Baseline | VeloDB Cloud result and evidence |
|---|---|---|---|---|
| Will the dashboard respond during peak traffic? | Replay dashboard queries with 50 concurrent clients while order changes arrive at the usual peak rate. | 95% of queries finish within 2 seconds (P95). | ||
| How soon can users see a change? | Update known orders at the source and measure the time from commit until the dashboard query returns each new value. | 95% of changes are visible within 10 seconds. | ||
| Can users trust the totals? | Compare order counts, net revenue by region, and the updated order values at the same source cutoff. | Order counts match exactly and net revenue matches to the cent. | ||
| Will the initial load fit the migration window? | Load a representative batch of known size and reconcile the loaded rows with the source. | All expected rows are accounted for within two hours. |
Add a row for any operational requirement that affects adoption. For example, if reporting and ingestion will use separate clusters, run them together on the planned clusters and check both targets. Include a cost ceiling if it affects the decision.
Select data, queries, and a baseline
- Choose the smallest set of tables that supports the tests. Include representative volumes from the largest tables and preserve the join relationships, time ranges, frequent values, and write patterns that affect the workload. If you need sample data to learn the workflow, start with the Quick Start.
- Select queries from the dashboard or application history. Include common filters and joins, a frequent interactive query, and a slow or expensive query. Save the SQL, parameters, execution frequency, and expected results. For ingestion, record the source volume, batch size, peak arrival rate, and mix of inserts and updates.
- Measure those workflows on the current system. Record latency, throughput, freshness, and resource usage as relevant to each target. Save the source snapshot or cutoff and the settings that affect comparisons, including the time zone and cache state. If the workload is new, use the agreed target and mark the baseline as unavailable.
Set up the test environment
Choose a warehouse with enough compute capacity for the sample workload. Record the deployment type, cloud provider and region, warehouse core version, cluster count, and size of each cluster. Connect from the client and network you expect to use in production. Confirm that the SQL user can load the test data and that the dashboard user can read the intended tables. See Connect to VeloDB Cloud.
Build and load the test dataset
For warehouse tables, choose a table design, load the representative data, and check the results against the source. If you only query data in place, connect the external catalog and use the data lake checks when you run your queries.
Table design
Create a table to match the way you write and query the data. These decisions affect ingestion and query performance:
- Data model
- Sort key
- Partitioning
- Bucketing
Data model
Choose the right model based on how data is written:
| Data Characteristic | Recommended Model | Reason |
|---|---|---|
| Append-only (logs, events, fact tables) | Duplicate Key (default) | Keeps all rows; best query performance |
| Updated by primary key (CDC, Upsert) | Unique Key | New rows replace old rows with the same key |
| Pre-aggregated metrics (PV, UV, summaries) | Aggregate Key | Merges rows by SUM/MAX/MIN at write time |
The Duplicate Key model fits most scenarios. Confirm the choice against your update and aggregation requirements. For details, see Data Model Overview.
Sort key
VeloDB Cloud builds a prefix index on the first 36 bytes of the sort key. When setting the sort key, follow these principles:
- Put high-frequency filter columns first: place columns most often used in
WHEREconditions at the front. - Put fixed-length types first: put fixed-length types such as
INT,BIGINT, andDATEbeforeVARCHAR, because the prefix index truncates immediately when it encounters aVARCHAR. - Add inverted indexes as a complement: for columns the prefix index does not cover, add an inverted index to speed up filtering.
Partitioning
If your workload filters by time, use AUTO PARTITION BY RANGE(date_trunc(time_col, 'day')) to enable partition pruning. VeloDB Cloud can then skip partitions that do not match the query predicate.
Bucketing
The default setting is random bucketing (recommended for Duplicate Key tables). If you frequently filter or JOIN on a specific column, use DISTRIBUTED BY HASH(that_column). For details, see Data Bucketing.
Choose an initial bucket count, then measure tablet sizes, data distribution, and query performance on the cluster that will run the workload.
| Bucket sizing guideline | What to check |
|---|---|
| For a fixed cluster, consider testing a multiple of the backend (BE) node count. | This can align initial tablet counts across workers. Check actual tablet sizes and query parallelism. Repeat the check after scaling or switching clusters. |
| Use the fewest buckets that provide enough parallelism. | Check for small tablets and files. |
| Start with compressed tablets of 20 GB or less for Duplicate Key and Aggregate Key tables, or 10 GB or less for Unique Key tables. | Run SHOW TABLETS FROM <your_table> to check tablet sizes. |
| Aim for at most 128 buckets per partition. | If you need more, evaluate adding partitions first. Before testing a high count such as 1,024, check the limit for your warehouse. |
Table creation templates
Log and event analytics
Use case: Append-only scenarios such as logs, events, and sensor data.
Prerequisites: No special requirements.
CREATE TABLE app_logs
(
log_time DATETIME NOT NULL,
log_level VARCHAR(10),
service_name VARCHAR(50),
trace_id VARCHAR(64),
message STRING,
INDEX idx_message (message) USING INVERTED PROPERTIES("parser" = "unicode")
)
AUTO PARTITION BY RANGE(date_trunc(`log_time`, 'day'))
()
DISTRIBUTED BY RANDOM BUCKETS 10;
Verification steps:
-- 1. Verify that partitions are created automatically
SHOW PARTITIONS FROM app_logs;
-- 2. Verify that data is evenly distributed
SHOW TABLETS FROM app_logs;
Real-time dashboards and upsert (CDC)
Use case: Scenarios that need primary-key updates, such as user profiles and order records.
Prerequisites: A clearly defined primary key column.
CREATE TABLE user_profiles
(
user_id BIGINT NOT NULL,
username VARCHAR(50),
email VARCHAR(100),
status TINYINT,
updated_at DATETIME
)
UNIQUE KEY(user_id)
DISTRIBUTED BY HASH(user_id) BUCKETS 10;
Verification steps:
-- 1. Verify primary key uniqueness (only one latest row per user_id)
SELECT user_id, count(*) as cnt FROM user_profiles GROUP BY user_id HAVING cnt > 1;
-- 2. Verify data distribution
SHOW TABLETS FROM user_profiles;
Metric aggregation
Use case: Scenarios that need pre-aggregation, such as traffic statistics and business reports.
Prerequisites: Clearly defined aggregation dimension columns and metric columns.
CREATE TABLE site_metrics
(
dt DATE NOT NULL,
site_id INT NOT NULL,
pv BIGINT SUM DEFAULT '0',
uv BIGINT MAX DEFAULT '0'
)
AGGREGATE KEY(dt, site_id)
AUTO PARTITION BY RANGE(date_trunc(`dt`, 'day'))
()
DISTRIBUTED BY HASH(site_id) BUCKETS 10;
Verification steps:
-- 1. Verify that aggregation works (metrics with the same dt+site_id are merged)
SELECT dt, site_id, pv, uv FROM site_metrics ORDER BY dt DESC LIMIT 10;
-- 2. Verify that partition pruning works
EXPLAIN SELECT * FROM site_metrics WHERE dt = '2024-01-01';
Data ingestion
Choose the right ingestion method and follow these best practices to avoid common performance issues:
- Do not use
INSERT INTO VALUESfor bulk data. Use Stream Load or Broker Load instead. For details, see Ingestion Overview. - Merge writes on the client side first. High-frequency small-batch ingestion causes version pile-up. If client-side merging is not feasible, use Group Commit.
- Split large ingestions into smaller batches. A long-running ingestion must restart from the beginning if it fails. For bounded batches in S3, use
INSERT INTO ... SELECTwith the S3 table-valued function and select the files for each batch. For ongoing ingestion, see Continuous Load Overview. - Enable
load_to_single_tabletfor Duplicate Key tables with random bucketing to reduce write amplification.
Quick verification:
-- View the status of a Broker Load job
SHOW LOAD WHERE label = 'your_label';
-- Check version pile-up. A high Version Count indicates ingestion may be too frequent.
SHOW TABLETS FROM your_table;
For details, see Load Best Practices and Performance Tuning.
Record the source rows or bytes and the elapsed time from the start of the load to completion. Divide the successfully loaded volume by that time to calculate throughput. For Broker Load, save the job status. For Stream Load, save the response, including the label and the loaded and filtered row counts. Account for any rejected rows before comparing query latency.
For change data capture (CDC), test an update as well as the initial load. With the user_profiles example, change a known user's status at the source, record the commit time, and poll for that user in VeloDB Cloud until the new status appears. Record the elapsed time and polling interval. Repeat for several updates to measure freshness. Use the same source cutoff to compare row counts and aggregates, and check that the updated rows contain the expected values.
Run the workload tests
Use the saved queries and parameters for each run. Record the cluster configuration, test duration, cache state, and data volume each time so you can explain differences between runs.
- Run the queries sequentially. Execute each query by itself to verify its result against the baseline. Repeat it under the same conditions and record elapsed time. For lakehouse queries, measure the first read of uncached data and repeated reads separately.
- Replay concurrent queries. Use your application or a load driver to replay the production mix. Increase concurrency in steps up to the expected peak. At each level, record completed queries per second, client-observed P95 latency, and timeouts or errors over the same measurement interval. Keep the SQL and data fixed.
- Add ingestion while queries are running. Repeat the peak-concurrency test with writes arriving at the expected production rate. Keep the read workload unchanged. Record query latency, write throughput, and the time until new data is visible. Compare with the query-only run to see whether either workflow misses its target.
For a slow or failed query, save its ID and test time. Use Query Audit to inspect the completed query and Metrics to check resource usage on the cluster during that interval.
Investigate missed targets
Start with the query or ingestion run that missed its target. For warehouse tables, check tablet distribution, indexes, and the Query Profile. For external tables, also check pruning, cache behavior, and file layout. After each change, rerun the affected test with the same inputs.
Query tuning
Bucket counts
The bucket count directly affects query parallelism and scheduling overhead, so you need to strike a balance:
- Do not use too many buckets. Too many small tablets create scheduling overhead and can reduce query performance by up to 50%.
- Do not use too few buckets. Too few tablets limit CPU parallelism.
- Avoid data skew. Use
SHOW TABLETSto check tablet sizes. When sizes differ significantly, switch to random bucketing or pick a bucketing column with higher cardinality.
The diagnostic SQL statement is as follows:
-- Check tablet size distribution (used to detect data skew)
SHOW TABLETS FROM <your_table>;
-- Review the tablet count and size to decide whether to adjust the bucket count
For more information about choosing the bucket count, see Bucketing.
Indexes
When using indexes, set the sort key correctly.
Unlike some databases such as PostgreSQL, VeloDB Cloud only indexes the first 36 bytes of the sort key, and it truncates immediately when it encounters a VARCHAR. Columns beyond the prefix range cannot benefit from the sort key and need an inverted index.
For more information, see Sort Key.
Inspect the scan predicates in the query plan. Then run the query and check RowsKeyRangeFiltered in its Query Profile to see how many rows the prefix index filtered.
EXPLAIN SELECT * FROM your_table WHERE filter_column = 'xxx';
-- Inspect the scan predicates on the sort key
Use Query Profile to diagnose slow queries
To diagnose slow queries, use Query Profile.
Enable profiling on the connection you use for the test query. For example, to inspect a lookup on the user_profiles table, run these statements.
SET enable_profile = true;
SELECT status FROM user_profiles WHERE user_id = 42;
SHOW QUERY PROFILE;
Use the returned query ID to find the full profile in SQL Editor history or Query Audit. Save the profile with the measured latency.
Data lake queries
If your POC queries Hive, Iceberg, or Paimon data through VeloDB Cloud, use the following checks. Lakehouse results depend on remote storage, file layout, network path, and cache state. Record those conditions with each measurement.
Make sure partition pruning works
Data lake tables often hold a massive amount of data. It is recommended that you always include the partition column in the WHERE clause to make VeloDB Cloud scan only the necessary partitions.
Run EXPLAIN <SQL> and then check the partition field to confirm that pruning works:
0:VPAIMON_SCAN_NODE(88)
inputSplitNum=15775, totalFileSize=951754154566, scanRanges=15775
partition=203/0
Compare plans with and without the partition predicate. In this Paimon example the scan still has 15,775 input splits. Read the partition field together with the split count and scan ranges. If the scan still covers more data than expected, verify that the WHERE clause matches the partition column.
Enable data cache
Remote storage, including Hadoop Distributed File System (HDFS) and object storage, generally has higher I/O latency than local disks. Data Cache stores recently accessed remote data on the cluster's local disk and can reduce latency for repeated queries while the data remains cached.
- Check the session setting before enabling external-table Data Cache. In SQL Editor, submit the cache settings and test query together with one Run action. See Data Cache for session controls and cache observation, and Manual Scaling for available cache-capacity adjustments.
- Before measuring warm-cache performance for external tables, use
WARM UP SELECTto preload the required data into the selected cluster's cache.
For warehouse internal tables, use WARM UP COMPUTE GROUP to create a cluster warmup job, then monitor it on the console's Warmup Jobs page. This is a separate workflow from external-table WARM UP SELECT.
Tip:
- During a POC, measure cold-cache and warm-cache running results separately. Use previously unread files for a cold run. Repeat the query on the same cluster and check the local and remote read metrics in the profile before labeling a run as warm.
- Do not use a warm-cache result as the only baseline for a workload that commonly reads new data.
Manage small files
Data lake workloads often contain a large number of small files. These files generate a large number of splits, increasing FE memory consumption and query planning overhead, and can even lead to OOM errors.
- Manage from the source (recommended): periodically merge small files on the Hive or Spark side, keeping each file larger than 128 MB.
- VeloDB Cloud fallback: use
SET max_file_split_num = 50000;(supported since v26.0.2) to adjust the target split count per scan when the legacy non-batch planner is in use. The actual count can exceed the target with many small files.
Use Query Profile to diagnose data lake slow queries
The bottleneck of data lake queries is usually IO rather than computation. You can use Query Profile to locate the root cause of slow queries.
Focus on the following:
- Split count and data volume: determine whether too much data is being scanned.
- MergeIO metrics: if
MergedBytesis much larger thanRequestBytes, read amplification is significant. The default value ofmerge_io_read_slice_size_bytesis8MB. Reducing it can mitigate read amplification. - Cache hit ratio: confirm that Data Cache is working effectively.
For more optimization techniques, see Data Lake Query Optimization.
Record and compare results
For each representative query and ingestion workflow, record the following:
- The warehouse deployment type, cluster count and sizes, and test data volume.
- The SQL statement, ingestion method, batch size, and concurrency.
- Ingestion throughput and freshness, and the load status or response for your ingestion method.
- Query latency for cold-cache and warm-cache running results, the
EXPLAINplan, and the Query Profile. - Tablet size distribution from
SHOW TABLETSand any data lake split or cache metrics.
Repeat the same workload after changing one variable at a time, such as the bucket count, sort key, or cache state. This practice makes each result easier to attribute and reproduce.
Quick checklist
- Does each table use the appropriate data model (Duplicate Key, Unique Key, or Aggregate Key)?
- Does the bucket count provide enough parallelism without creating too many small tablets? If you tested a multiple of the backend count, did you check the actual distribution?
- Do time-based queries include the partition column so that partition pruning can occur?
- For lakehouse queries, have you measured both a cold-cache and a warm-cache run?
- Have you recorded the query plan, Query Profile, ingestion status, and tablet distribution for the representative workload?
Decide whether to proceed
Return to the acceptance table. For each row, enter the measured value, whether it met the target, and the query ID, load record, or reconciliation result that supports it. Record the cluster configuration, SQL rewrites, and table design changes required to reach that result.
Compare the cost of completing the same amount of work at each configuration that met the targets. For a steady compute rate, multiply the hourly rate by the run duration in hours. For example, a 20-minute run at an assumed $3 per hour uses $1 of compute. A one-hour run at $2 per hour uses $2 for the same work. Use your own rates and include applicable storage, cache, and cloud-provider charges when comparing total cost. Use Usage to review warehouse metering for the test period.
Agree with the workload owner whether to proceed, retest a specific change, or stop. For each unresolved requirement, record the gap, its owner, and the test that would close it. When testing is complete, stop test ingestion and clients. If you used a dedicated test cluster, pause it when idle and review any continuing storage and cache charges.
Common errors and solutions
Table creation fails with Tablet count should be greater than 0
Cause:
- The bucket count is set to
0. - Or bucketing is not specified.
Solution:
Verify that the DDL specifies a distribution method and a positive bucket count, such as DISTRIBUTED BY HASH(column_name) BUCKETS n or DISTRIBUTED BY RANDOM BUCKETS n.
-- Correct example
DISTRIBUTED BY HASH(user_id) BUCKETS 10;
A slow query is not using the expected index
Diagnosis steps:
- Run
EXPLAIN <query>to inspect the scan predicates on the sort key. - Run
SHOW TABLETS FROM <table_name>to verify that tablet sizes are even. - View the Query Profile to locate the bottleneck. For the prefix index, check
RowsKeyRangeFiltered.
-- Inspect the scan predicates on the sort key
EXPLAIN SELECT * FROM <table_name> WHERE key_col = 'xxx';
-- Check tablet size to detect data skew
SHOW TABLETS FROM <table_name>;
OOM on data lake queries
Cause:
Too many small files cause the split count to explode.
Solution:
-
Merge small files on the data source side. Make sure that each file is larger than 128 MB.
-
For legacy non-batch split planning, set a target split count and recheck the resulting plan.
SET max_file_split_num = 50000;
Ingestion version pile-up causes slow queries
Cause:
Frequent small-batch ingestion creates too many versions.
Solution:
-
Merge ingestion batches and reduce ingestion frequency.
-
Enable Group Commit:
SET group_commit = async_mode;
FAQ
Q: How long does a POC take?
The time required depends on the dataset, workload, and validation scope. Start with table creation, ingestion, and representative queries, then allow additional time for performance tuning and repeated measurements.
Q: How should I choose the bucket count when creating a table?
For a fixed cluster, you can start by testing a multiple of its backend node count. Check tablet sizes and query parallelism under your expected load, and repeat after scaling.
Use the following compressed sizes per tablet as starting points:
- Less than 20 GB for Duplicate Key and Aggregate Key tables
- Less than 10 GB for Unique Key tables
Q: What should I do if queries are slower than expected?
Do the following:
- Run
EXPLAINto inspect the scan predicates, then check the relevant index counters in the profile. - Run
SHOW TABLETSto check for data skew. - View the Query Profile to locate the bottleneck.
Q: Should I enable Data Cache?
If your workload includes data lake queries, such as Hive, Iceberg, or Paimon, consider evaluating Data Cache.
Compare query latency with a cold cache and a warm cache: a first read of uncached data can populate the cache, and subsequent queries may benefit. Confirm the cache state with the profile.