starrocks-cbo

Correct StarRocks CBO statistics and join strategies using ANALYZE TABLE and EXPLAIN COSTS.

14|1|Updated May 5, 2026
One-click install
npx skills add https://github.com/ivanshamaev/de-agent-skills --skill starrocks-cbo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: starrocks-cbo
Source: https://github.com/ivanshamaev/de-agent-skills/tree/main/group_skills/starrocks_group_skills/starrocks_cbo
Command: npx skills add https://github.com/ivanshamaev/de-agent-skills --skill starrocks-cbo

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill addresses slow or inefficient StarRocks queries caused by stale or missing optimizer statistics, leading to wrong join strategies, bad cardinality estimates, and poor execution plans.

Core Features & Use Cases

  • ANALYZE TABLE for CBO statistics: Collect full, sampled, histogram, predicate-column, and partition-level statistics to refresh the cost model after ETL or bulk loads.
  • Auto analyze configuration & monitoring: Enable and tune automatic statistics collection, then verify outcomes using SHOW ANALYZE STATUS and targeted maintenance workflows.
  • Diagnose plan issues with EXPLAIN COSTS: Identify cardinality estimation errors and apply fixes via updated stats, histograms, or controlled optimizer hints (LEADING, BROADCAST/SHUFFLE, SET_VAR).
  • Multi-column statistics for correlated filters: Improve selectivity estimation when single-column stats fail due to column correlation (StarRocks 3.5+).

Use case example: after a daily bulk load into an orders table, activate this skill to re-ANALYZE the affected partitions (and add histograms for skewed columns) so that join order and join type chosen by the CBO match real data distribution.

Quick Start

Use the starrocks-cbo skill to run ANALYZE TABLE for the affected orders table (including histogram or sampled stats as appropriate) and then confirm the improvement with EXPLAIN COSTS on your problematic join query.

Frequently Asked Questions about starrocks-cbo

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does StarRocks choose a bad join strategy and how do I fix slow query performance?

Slow StarRocks queries often stem from stale or missing cost-based optimizer statistics. Fix bad join strategies and poor execution plans by collecting full, sampled, and histogram statistics with ANALYZE TABLE to refresh the cost model.

How do I re-analyze StarRocks table partitions after a daily bulk load to fix join performance?

To re-analyze StarRocks table partitions after a bulk load, run ANALYZE TABLE on the affected tables and add histograms for skewed columns. This updates the cost model so the join order matches the real data distribution.

How can I diagnose StarRocks cardinality estimation errors in my execution plan?

Diagnose StarRocks cardinality estimation errors by running EXPLAIN COSTS on your problematic join query. This identifies bad estimates so you can apply fixes like updated statistics, histograms, or controlled optimizer hints.

When do I need multi-column statistics in StarRocks for correlated filters?

You need StarRocks multi-column statistics when single-column stats fail due to column correlation. Available in StarRocks 3.5+, multi-column statistics improve selectivity estimation for correlated filters and eliminate cardinality estimation failures.

Can I apply join hints to control the StarRocks cost-based optimizer?

You can apply targeted StarRocks join hints like LEADING, BROADCAST, SHUFFLE, and SET_VAR to control the cost-based optimizer. Use these to manually override bad join order or join type decisions when updated statistics alone are insufficient.

How do I configure and monitor automatic statistics collection in StarRocks?

Configure and monitor StarRocks automatic statistics collection by enabling auto analyze and verifying outcomes using SHOW ANALYZE STATUS. This establishes targeted maintenance workflows to ensure production-ready statistic collection scheduling.