- Posted on
- admin
- No Comments
What Is StarRocks? Complete Guide
Dashboards used to be forgiving. A report that took a minute to load was normal, because a handful of analysts looked at it once a day. Then analytics moved into products. Now thousands of customers click through filters on a live page, each click fires a query with several joins, and everyone expects an answer before they’ve moved their mouse.
StarRocks was built for that world. It’s an analytical database that returns results from large, constantly updated datasets in well under a second, speaks the MySQL protocol so existing tools connect to it, and can also query data that sits in a data lake without copying it first. This guide explains what StarRocks is, where it came from, how its architecture works, which table types and features matter, and how to run it yourself with Docker. If you’ve read our ClickHouse tutorial for beginners, you’ll recognize the problem space, and we’ll point out where the two approaches differ.
What Is StarRocks?
StarRocks is an open-source, distributed OLAP database, which means it’s designed for analytical queries: scanning and aggregating a lot of data across many columns. (cite index=”104-1″>The project describes itself as an open query engine for sub-second, ad hoc analytics both on and off the data lakehouse, and it’s a Linux Foundation project. In plainer terms, it’s meant to answer interactive questions quickly whether the data is stored inside StarRocks or sitting in lake storage.
A few characteristics define it:
- A fully vectorized engine. (cite index=”107-1″>It processes data in column batches to exploit modern CPU SIMD instructions.
- A cost-based optimizer. (cite index=”107-1″>The optimizer uses table and column statistics to choose efficient join orders and access paths.
- MySQL compatibility. (cite index=”104-1″>It supports ANSI SQL, with TPC-H and TPC-DS fully supported, and it’s compatible with the MySQL protocol, so a variety of clients and BI tools can connect.
- A permissive license. (cite index=”98-1″>StarRocks is licensed under Apache License 2.0.
Like most projects in this category, StarRocks publishes bold performance claims. Its README says its native vectorized engine achieves sub-second multi-dimensional analysis that is 5 to 10 times faster than previous systems. Treat figures like that as the vendor’s framing and test your own queries, but they accurately signal the design priority: speed on analytical joins and aggregations.
Where StarRocks Came From
The project’s history explains a lot about its design and its relationship to a better-known neighbor.
(cite index=”107-1″>StarRocks started in 2020 as a fork of Apache Doris, first released as DorisDB, and has since evolved into a separate project. (cite index=”107-1″>Its maintainers rewrote large parts of the engine, adding a fully vectorized execution layer, a cost-based optimizer, and the shared-data deployment mode.
Governance has changed too. (cite index=”107-1″>StarRocks has been hosted under the Linux Foundation since 2023. Even so, one independent comparison notes that (cite index=”106-1″>development is more strongly steered by CelerData, the company behind it, which is useful context if you’re weighing who shapes the roadmap.
That same comparison offers a succinct view of how StarRocks and Doris diverged. (cite index=”106-1″>StarRocks has gone deep on the lakehouse, with external catalogs, cross-catalog joins, materialized views over Iceberg, and shared-data compute, while Doris has gone broad, adding inverted indexes for log search and a variant type for semi-structured data. Both remain MySQL-protocol OLAP engines with a similar overall shape.
How StarRocks Works: The Architecture
StarRocks keeps its architecture deliberately simple, with a small number of node types and two deployment modes.
Frontend and Backend Nodes
(cite index=”104-1″>StarRocks’s architecture is mainly composed of two modules: Frontend (FE) and Backend (BE).
The Frontend is the control plane. (cite index=”101-1″>FE nodes use the cost-based optimizer to check SQL statements and generate execution plans optimized for distributed processing. The FE also manages metadata and coordinates the cluster. When a client connects over the MySQL protocol, it’s talking to an FE.
The Backend does the heavy lifting in the classic mode. (cite index=”107-1″>Backend nodes store data and execute query fragments locally. A query is split into fragments, spread across the BEs that hold the relevant data, executed in parallel, and the partial results are combined. That’s the MPP, or massively parallel processing, model.
Shared-Nothing vs Shared-Data
StarRocks offers two ways to arrange storage and compute, and choosing between them is one of your first architectural decisions.
Shared-nothing. (cite index=”105-1″>In this model StarRocks consists of two types of nodes, FEs and BEs. Each BE owns a slice of the data on its local disks and computes against it. It’s the original design, with storage and compute coupled together, and it delivers excellent speed because data is right next to the CPU.
Shared-data. (cite index=”104-1″>Starting from version 3.0, StarRocks supports a shared-data architecture that can provide better scalability and lower costs. (cite index=”105-1″>Here, BEs are replaced by compute nodes, or CNs, which are responsible only for compute and for caching hot data. Persistent data lives in external object storage.
The practical benefits of shared-data follow directly. (cite index=”101-1″>Because persistent data is stored externally, adding a compute node doesn’t require moving existing data between nodes, so scaling out is quick. (cite index=”105-1″>The approach reduces storage cost, improves resource isolation, and provides elasticity and scalability. And (cite index=”105-1″>by keeping hot data close to compute units, it aims to keep performance high while storage stays cheap.
(cite index=”105-1″>In a shared-data cluster, the data file format stays consistent with a shared-nothing one, and the FEs provide the same functions in both. That means the concepts you learn transfer, and the choice is mostly about economics and elasticity. This separation of storage and compute is the same idea we described for ClickHouse Cloud in our ClickHouse architecture guide.
The Query Engine
Two components deserve a closer look, because they’re the heart of StarRocks’ speed.
Vectorized Execution
A vectorized engine processes a batch of values from a column in one tight loop, rather than handling one row at a time with a function call per value. That’s friendlier to CPU caches and lets the processor apply SIMD instructions across many values at once. The same idea powers DuckDB and ClickHouse, which we cover in our DuckDB tutorial. StarRocks pairs it with predicate pushdown to storage, so filters are applied as early as possible and unneeded data is never read.
The Cost-Based Optimizer
Joins are where StarRocks puts particular emphasis. Many real-time analytics engines prefer wide, denormalized tables because joins are costly. StarRocks’ optimizer is designed to make joins on normalized schemas practical.
Its README describes the result as a query engine that (cite index=”104-1″>eliminates the need for denormalization and adapts to your use cases without moving data or rewriting SQL, which is, again, the project’s own claim. If your data model is a classic star or snowflake schema, this is a major part of the appeal.
(cite index=”107-1″>Together, vectorized execution, predicate pushdown, and the optimizer are intended to let StarRocks serve many simultaneous dashboard users without the latency spikes typical of batch-oriented warehouses. High concurrency is a recurring theme, because customer-facing analytics means many small queries at once rather than a few giant ones.
Table Types: Choosing a Data Model
When you create a table in StarRocks, you pick a model that controls how rows with the same key are treated. This is one of the most important design decisions, and it’s more explicit than in many databases.
(cite index=”113-1″>StarRocks provides four types of tables, Duplicate Key, Primary Key, Aggregate, and Unique Key, covering scenarios such as raw data, frequently updated real-time data, and aggregated data.
Duplicate Key tables. (cite index=”110-1″>Duplicate Key is the default type. (cite index=”114-1″>Rows with identical content in the key columns coexist. The key columns act as the sort key, and nothing is merged or deduplicated. This is the right choice for raw events and logs, and it’s the simplest to reason about.
Primary Key tables. (cite index=”113-1″>These add unique and non-null constraints to the primary key columns. (cite index=”114-1″>When rows share the same key, newer values replace earlier ones according to import order, which gives you upsert behavior. If your data changes, for example order statuses or user profiles synced from an operational database, this is the model to reach for.
(cite index=”112-1″>One cloud vendor’s documentation says that for upsert streams the Primary Key model must be used, and reports 3 to 10 times better query performance than the merge-on-read Unique Key model. That’s a vendor claim, but the direction is consistent with design: Primary Key tables resolve updates at write time so reads stay fast.
Aggregate tables. They pre-aggregate rows that share a key using functions like SUM, so storage holds rolled-up values instead of raw rows. Good for fixed metrics you never need to drill below.
Unique Key tables. An older model that also replaces rows by key but uses a merge-on-read approach. For new designs with updates, Primary Key tables are generally the better starting point.
Every table also needs a distribution strategy. (cite index=”113-1″>With hash bucketing, data is distributed into buckets based on the hash values of the bucketing key. Choosing a bucketing key with plenty of distinct values spreads data and work evenly across nodes.
Materialized Views
StarRocks leans on materialized views to make repeated queries cheap. (cite index=”98-1″>Its materialized views can be updated automatically during data import and are selected automatically when a query executes. That last part is important. You don’t rewrite your query to use the view. The optimizer recognizes when a view can answer a query, or part of it, and substitutes it.
The feature extends to the lakehouse. As noted earlier, StarRocks supports materialized views over Iceberg tables, so you can keep a fast, pre-aggregated copy of lake data inside the cluster while the source stays in object storage.
Querying the Data Lake
This is a headline feature. (cite index=”102-1″>StarRocks can access data in Apache Hive, Apache Iceberg, Delta Lake, and Apache Hudi directly, without importing it. You register an external catalog that points to your lake, and then query those tables with ordinary SQL, even joining them with tables stored natively in StarRocks.
This positions StarRocks in a middle ground. You can leave cold or shared data in open table formats and query it in place, while loading the hot, frequently queried subset into native tables for the best latency. If open table formats are new to you, our Apache Iceberg tutorial and Delta Lake guide explain what’s underneath. Teams that already use Trino for federated queries, covered in our Trino guide, will find the catalog idea familiar.
Loading Data
Data gets into StarRocks in several ways, and the best choice depends on volume and freshness.
- Stream Load. (cite index=”111-1″>Transfers data over HTTP, allowing direct import of local data without relying on other systems or components. It’s handy for files and for applications that batch data themselves.
- Streaming and CDC pipelines. (cite index=”112-1″>Flink connectors can load data from MySQL CDC into a StarRocks table, and for upsert streams the target should use the Primary Key model.
- Sinks from other systems. (cite index=”115-1″>RisingWave, for instance, can sink to StarRocks, and recommends Primary Key tables, which can deduplicate data and achieve end-to-end idempotent writes. If you’ve followed our RisingWave guides, that’s a natural way to feed live, joined results into an analytical store.
- Plain INSERT statements. Fine for small amounts of data, such as when you’re learning.
A general rule applies across all of them: prefer fewer, larger loads over many tiny ones. Small frequent loads create lots of small data versions that the system has to compact later.
Hands-On Quickstart
Let’s run StarRocks and create a few tables. You’ll need Docker and, ideally, a MySQL client.
Step 1: Start a Single-Node Cluster
(cite index=”108-1″>The all-in-one image runs a complete test cluster in one container:
docker pull starrocks/allin1-ubuntu
docker run -p 9030:9030 -p 8030:8030 -p 8040:8040 -itd \
--name quickstart starrocks/allin1-ubuntuPort 9030 is the MySQL-protocol port you’ll connect to. The others serve the HTTP interfaces used for loading and monitoring. Give the container a minute to start.
Step 2: Connect With the MySQL Client
(cite index=”108-1″>The easiest approach is to run the MySQL CLI inside the container:
docker exec -it quickstart \
mysql -P 9030 -h 127.0.0.1 -u root --prompt="StarRocks > "You can also use DBeaver or MySQL Workbench against the same port, which shows how much of the MySQL ecosystem works out of the box.
Step 3: Create a Database and a Duplicate Key Table
CREATE DATABASE IF NOT EXISTS demo;
USE demo;
CREATE TABLE page_events (
event_id BIGINT,
user_id INT,
page VARCHAR(100),
country VARCHAR(10),
event_time DATETIME
)
DUPLICATE KEY(event_id)
DISTRIBUTED BY HASH(event_id) BUCKETS 4
PROPERTIES ("replication_num" = "1");The replication_num property matters on a single-node test cluster, because the default asks for multiple replicas and a lone node can’t satisfy that. In a real cluster you’d keep the default or set it deliberately.
Step 4: Insert and Query
INSERT INTO page_events VALUES
(1, 101, '/home', 'IN', '2026-01-15 10:00:01'),
(2, 102, '/pricing', 'US', '2026-01-15 10:00:05'),
(3, 101, '/docs', 'IN', '2026-01-15 10:01:12'),
(4, 103, '/home', 'DE', '2026-01-15 10:02:30'),
(5, 104, '/home', 'US', '2026-01-15 10:03:44'),
(6, 102, '/docs', 'US', '2026-01-15 10:04:10'),
(7, 105, '/pricing', 'IN', '2026-01-15 10:05:55'),
(8, 101, '/home', 'IN', '2026-01-15 10:06:20');
SELECT country,
COUNT(*) AS views,
COUNT(DISTINCT user_id) AS visitors
FROM page_events
GROUP BY country
ORDER BY views DESC;The query syntax should feel completely ordinary, because it’s MySQL-flavored SQL. The difference is what happens underneath when the table has billions of rows rather than eight.
Step 5: Try a Primary Key Table for Upserts
CREATE TABLE users (
user_id INT NOT NULL,
name VARCHAR(50),
plan VARCHAR(20)
)
PRIMARY KEY(user_id)
DISTRIBUTED BY HASH(user_id) BUCKETS 4
PROPERTIES ("replication_num" = "1");
INSERT INTO users VALUES (101, 'Asha', 'free'), (102, 'Ravi', 'free');
INSERT INTO users VALUES (101, 'Asha', 'pro');
SELECT * FROM users ORDER BY user_id;User 101 appears once, with the plan pro. The second insert replaced the earlier row because the primary key matched, exactly the replace-by-key behavior described in the table types section.
Step 6: Join the Two Tables
SELECT u.plan,
COUNT(*) AS views
FROM page_events e
JOIN users u ON e.user_id = u.user_id
GROUP BY u.plan;Joining a fact table to a dimension table is routine here, and it’s the kind of query the optimizer is designed to handle well at scale.
Step 7: Add a Materialized View
CREATE MATERIALIZED VIEW daily_page_views
REFRESH ASYNC
AS
SELECT DATE(event_time) AS day,
page,
COUNT(*) AS views
FROM page_events
GROUP BY DATE(event_time), page;
SELECT * FROM daily_page_views ORDER BY day, page;Materialized view syntax and refresh options vary by version, so check the documentation for yours if this statement is rejected. Once the view exists, run EXPLAIN on a query that groups by day and page, and look for the plan referencing the view. That’s the automatic rewrite in action.
Step 8: A Peek at Lake Querying
You won’t run this in the quickstart because it needs an actual lake, but the shape is worth seeing. You create an external catalog pointing at a metastore or REST catalog, then switch to it:
CREATE EXTERNAL CATALOG iceberg_lake
PROPERTIES (
"type" = "iceberg",
"iceberg.catalog.type" = "rest",
"iceberg.catalog.uri" = "http://your-rest-catalog:8181"
);
SET CATALOG iceberg_lake;
SHOW DATABASES;Property names depend on your catalog type, so follow the current documentation for Hive, Glue, REST, or others. After that, tables in the lake are queryable with the same SQL, and you can join them to native tables by using fully qualified names.
Step 9: Clean Up
DROP MATERIALIZED VIEW daily_page_views;
DROP TABLE users;
DROP TABLE page_events;
DROP DATABASE demo;Then stop the container with docker stop quickstart && docker rm quickstart.
Common Beginner Mistakes to Avoid
Forgetting replication on a one-node cluster. The classic first error is a table creation failure complaining about replica counts. Set replication_num to 1 for local testing.
Choosing the wrong table model. Using a Duplicate Key table for data that gets updated leaves stale duplicates around. Use a Primary Key table when rows change, and a Duplicate Key table for append-only events.
Picking a poor bucketing key. A key with few distinct values concentrates data on a few nodes. Choose a high-cardinality column that’s also reasonably aligned with your joins.
Loading data in tiny batches. As covered above, frequent small loads create overhead. Batch them, or use a streaming connector that does it for you.
Assuming it’s MySQL underneath. The protocol and much of the SQL are MySQL-compatible, so tools connect easily, but StarRocks is an analytical engine. It’s not a transactional replacement for MySQL.
Neglecting statistics. The optimizer’s join choices rely on table and column statistics. Make sure they’re collected on large tables so plans stay efficient.
StarRocks vs ClickHouse and Doris, Briefly
The obvious comparisons are with ClickHouse and Apache Doris. Against Doris, the story is shared ancestry and divergent emphasis: StarRocks leans into the lakehouse and join performance, while Doris has broadened its feature set. Against ClickHouse, a few contrasts stand out. ClickHouse is famous for scanning huge denormalized, append-oriented event tables and tends to favor wide tables.
StarRocks emphasizes joins on normalized schemas, MySQL protocol compatibility, built-in upsert tables, and querying lake data directly. Both are fast, both are open source under Apache 2.0, and the right pick depends on your data model and workload. If you want a sense of how the ClickHouse side works, our ClickHouse architecture guide covers it in depth. As always, validate with your own data, since published benchmarks come with the vendor’s incentives.
Who Should Use StarRocks?
StarRocks tends to be a strong fit when:
- You’re building customer-facing or high-concurrency analytics that must return in under a second.
- Your data is modeled with joins across fact and dimension tables rather than one giant flat table.
- You need real-time upserts from operational databases through CDC.
- You want to query lakehouse data in Iceberg, Hudi, Delta Lake, or Hive without moving it.
- Your team and tools already speak MySQL.
It’s a weaker fit for transactional workloads, for tiny datasets that a single PostgreSQL instance handles easily, and for teams that want a single-node embedded engine, where DuckDB is simpler.
Frequently Asked Questions
Is StarRocks free and open source? Yes. It’s licensed under Apache 2.0, and it’s a Linux Foundation project. A commercial company, CelerData, also offers managed and enterprise products built on it.
Is StarRocks a fork of Apache Doris? Originally, yes. It started in 2020 as DorisDB, a fork of Apache Doris, and has since evolved into a separate project with a rewritten vectorized engine, a cost-based optimizer, and a shared-data mode.
What does MySQL compatible mean? StarRocks speaks the MySQL wire protocol and a largely compatible SQL dialect, so MySQL clients, drivers, and many BI tools can connect to it. It doesn’t mean it behaves like a transactional MySQL database.
What’s the difference between shared-nothing and shared-data mode? In shared-nothing, backend nodes store data locally and compute on it. In shared-data, data lives in object storage and compute nodes cache hot data, so storage and compute scale independently and adding compute doesn’t require moving data.
Which table type should I use? Use Duplicate Key tables for append-only data such as events and logs, and Primary Key tables when rows are updated or upserted. Aggregate tables suit pre-rolled-up metrics.
Can StarRocks query Iceberg or Delta Lake tables? Yes. It can read Hive, Iceberg, Delta Lake, and Hudi tables directly through external catalogs without importing the data.
Is StarRocks good for joins? Joins are a particular focus. Its cost-based optimizer is designed to make joins on normalized schemas efficient, which reduces the need to denormalize everything into wide tables.
How is StarRocks different from ClickHouse? Both are fast columnar analytics engines. StarRocks emphasizes joins, MySQL protocol compatibility, built-in upsert tables, and direct lakehouse queries, while ClickHouse is especially strong at scanning large denormalized event tables with its MergeTree engines.
Final Thoughts
StarRocks occupies a distinctive spot: an analytical database tuned for high-concurrency, sub-second queries, comfortable with real joins, able to absorb updates through Primary Key tables, and willing to read a data lake in place. Its simple FE and BE structure, plus the option of shared-data mode for elastic, object-storage-backed scaling, keeps it approachable, and the MySQL protocol removes a lot of tooling friction.
The best way to judge it is to run the quickstart, load a slice of your own data, and test the queries your product actually needs. For authoritative detail on every feature mentioned here, StarRocks’ official documentation is the best place to go deeper.
For more breakdowns of open-source data infrastructure and real-time analytics tooling like this one, keep exploring the guides on CourseDrill.
Popular Courses
