← Status board  /  Phase 5

Phase 5 — Benchmark and query profiles Four queries, two engines, five measured runs each after two discarded warm-ups. StarRocks wins three and loses one, and every result comes with the operator that produced it. Nothing in this report is a hypothesis any more.

Status complete Runs 2 warm-up + 5 measured Result 3 wins · 1 loss Headline 130× Q1 Next Phase 6 · Report

1 Summary

The question was never "is StarRocks faster". It was in which queries, by how much, and why. Four queries were fixed before any measurement, each with a predicted winner, and all four landed where the hypothesis said they would — including the loss.

Q1 aggregation
130×
334 ms vs 43,425 ms · StarRocks
Q4 join + top-N
58×
472 ms vs 27,429 ms · StarRocks
Q2a substring
22.6×
648 ms vs 14,670 ms · StarRocks
Q3 point lookup
2.2×
80 ms vs 173 ms · MySQL wins
The one-sentence answer

StarRocks wins wherever the question is an aggregation over many rows, loses where the question is one row by key, and the gap in every case is explained by the plan: temporary tables and nested loops on one side, columnar scans and vectorised hash aggregation on the other.

2 Method — and the four things that make it defensible

RuleHow it was applied
Warm cache, both sides2 warm-up runs per query per engine, discarded. The measured runs therefore never pay for the first read of a page.
Never the best time5 measured runs; median and p95 are reported. The best run appears in the CSV as min_ms and is used nowhere in this report.
Same client, measured overheadBoth engines are queried with the same mysql binary inside the same container. The cost of one empty round trip was measured first — 80 ms to StarRocks, 75 ms to MySQL — and is reported next to every figure so it can be subtracted by the reader.
Result proven, not assumedEach query's output is normalised (decimals to two places) and checksummed. Identical checksums on Q1, Q3 and Q4 prove both engines returned the same rows, not just the same number of rows.
Why the client overhead had to be measured, not assumed

A point lookup that answers in 5 ms cannot be measured with a 75 ms instrument and reported as "80 ms". Every table below therefore carries a second row: the median with the baseline subtracted. For Q1 to Q4 the subtraction changes the ratio by tens of percent, so hiding it would have been a choice, not an oversight.

3 Results

QueryStarRocks
median
MySQL
median
Ratiop95 SRp95 MYWinner
Q1334 ms43,425 ms130.0×391 ms48,695 msStarRocks
Q2a648 ms14,670 ms22.6×719 ms16,747 msStarRocks
Q3173 ms80 ms0.46×192 ms98 msMySQL
Q4472 ms27,429 ms58.1×588 ms34,403 msStarRocks

With the client round trip removed

QuerySR adjustedMySQL adjustedRatioReading
Q1254 ms43,350 ms170.7×The gap grows when the constant is removed — it was never an artefact of the client.
Q2a568 ms14,595 ms25.7×Same direction, slightly larger.
Q393 ms5 ms0.05×The loss is 18.6×, not 2.2×. Without the baseline, Q3 flatters StarRocks.
Q4392 ms27,354 ms69.8×Same direction, larger.
The honest headline for Q3

2.2× is what a stopwatch on the command line says. 18.6× is what the engines actually cost. The report uses the adjusted figure for the loss and states both, because a benchmark that under-reports its own losses is not a benchmark.

Run by run

QueryEngineminmedianp95maxRows
Q1SR31833439139950
Q1MY41,87243,42548,69549,09450
Q2aSR5556487197361
Q2aMY13,12514,67016,74716,9031
Q3SR1261731921931
Q3MY7280981001
Q4SR449472588600100
Q4MY25,11927,42934,40335,580100

4 Q1 — why 130×

Both engines produce the same 50 rows, checksum 1afc3c24…. The difference is entirely in how they get there.

StarRocks: 334 ms

OLAP_SCAN           1,309,594 rows   164.9 ms ScanTime
AGGREGATION [partial]  122,394 groups  390.9 ms CPU
SHUFFLE                                23.7 ms
AGGREGATION [final]     74,833 groups   69.7 ms
TOP_N                        50 rows     1.9 ms

One columnar read of the columns the query names, a partial aggregation per bucket, a shuffle of 122k partial groups, a merge to 74.8k, and a top-N. There is no point in the plan where a whole row is assembled.

MySQL: 43,425 ms

Table scan on contratos   1.31 M rows    6,044 ms
Aggregate using temporary  74,833 groups 43,015 ms
Sort total DESC, LIMIT 50                43,134 ms

The scan is 6 seconds. The other 37 are the temporary table: with no index on (codigo_entidad, anio) MySQL cannot stream the GROUP BY, so it maintains 74,833 groups row by row and then sorts the result.

What this is not

It is not "MySQL is a bad database". It is a row store doing a job it was not indexed for, against a columnar engine doing the job it was built for. Add a covering index and this number changes; the point of the query is that nobody indexes a 1.3 M-row table for every ad-hoc aggregation.

5 Q2a — the substring that no index can serve

LIKE '%computadores%' is the one text question both engines answer by reading everything: a leading wildcard rules out a B-tree, and MySQL's FULLTEXT index cannot serve it either. This is the fair text comparison, and it is separate from the annex in section 9.

EngineMedianRowsChecksum
StarRocks648 ms2,01835f0d6be…
MySQL14,670 ms2,020bd3650b0…

The checksums differ, and the reason is not performance: MySQL's utf8mb4_0900_ai_ci folds the accent in CÓMPUTADORES, StarRocks compares bytes. Two extra rows out of 2,020 — 0.1 %. The timings remain comparable because both engines scanned the same 1.31 M rows; the predicates differ by one accent rule, not by a different question.

A trap that was avoided before the first run

Without LOWER(), StarRocks returns zero rows, because the stored text is uppercase and its comparison is byte-exact. Running that version would have produced a spectacular, entirely fake 0 ms "win". The rule went into the query files before measurement, not after seeing an odd number.

6 Q3 — the loss, and why it is structural

One row by (anio, id): StarRocks 173 ms, MySQL 80 ms. Adjusted: 93 ms against 5 ms.

MySQL: the row is the index leaf

InnoDB clusters the table on PRIMARY KEY (id). The row lives inside the B-tree, so the lookup is three or four page levels and the row is already in the buffer pool. There is nothing to assemble: the page is the row.

StarRocks: no point index, by design

The sort key is (anio, id) and the data is bucketed by hash; finding one row still means planning the query, opening the partition, reading the bucket and assembling fourteen columns from separate column files. That is the price of the columnar model, and it is paid on every point lookup.

Why the query is shaped this way

WHERE id = ? alone would scan all 25 partitions and turn a 2.2× loss into a 50× one. That would be a real number about a query nobody writes. The pair (anio, id) is what the sort key supports and what a person with a contract reference and a year would actually type.

7 Q4 — the join MySQL chose to do the hard way

Same 100 rows, checksum 1702ec04…. The dimension entidades holds 13,183 rows on both engines, built from the same subset with the same statement.

StarRocks: 472 ms

Hash join against a 13k-row build side, filter on anio >= 2020, two-stage vectorised aggregation, top-N. The plan the optimiser produced is the plan the query asks for.

MySQL: 27,429 ms

Table scan on c              4,669 ms
Filter anio >= 2020   570,192 rows
Nested loop + 570,192
  single-row index lookups   4,994 ms
Aggregate into temporary    13,069 ms
HAVING + Sort              22,847 ms total

The optimiser chose a nested loop with one index lookup per surviving row instead of a hash join, then built another temporary table to group. Two serial costs where StarRocks pays one parallel one.

8 Sensitivity — is the 130× an artefact of my own SQL?

Fair question, because the queries cast the sum to DECIMAL(20,0) so the two engines print identical integers. Decimal arithmetic is slower than double, and if it penalised only the row store the ratio would be inflated. So it was measured.

Q1 variantStarRocksMySQLRatioNote
SUM(CAST(... AS DECIMAL(20,0)))334 ms43,425 ms130×The measured figure used everywhere else in this report.
SUM(valor) plain double≈ 425 ms≈ 36,545 ms86×Control: 2 MySQL runs (32,902 / 40,189 ms), 5 StarRocks runs (346–446 ms).

The cast costs MySQL 3–7 seconds of its 43 and StarRocks about 100 ms. So the 130× is inflated by roughly 50 % against the plain-double figure of 86×, and both are published. The cast stays because it is what makes the checksum meaningful: without it the two engines sum in different orders and the last bits of the double differ, which would turn a proof of equality into noise.

9 Q2b annex — native text search, and the absence of a twin

Not comparable, kept out of the results table. It answers a different question: what does each engine do when allowed to use its own text machinery?

Engine / pathMedianRowsStatus
MySQL · MATCH…AGAINST (FULLTEXT)65 ms1,979Runs 55–105 ms over five runs.
MySQL · LIKE (same column, same word)14,670 ms2,020From Q2a.
StarRocks · native text——Not available on this table.
The finding

MySQL's FULLTEXT path is ≈226× faster than its own LIKE on the same column. The gap inside one engine is larger than the gap between the two engines — so the lesson of the annex is not "MySQL beats StarRocks at text", it is "whoever does not use the native index loses two orders of magnitude against themselves".

Why StarRocks has no number here

Two attempts, two different errors, both measured on 3.5.21:

ALTER TABLE ... ADD INDEX idx_detalle_inv (detalle) USING INVERTED;
  -> ERROR 1064: Unexpected input 'INVERTED',
     the most similar input is {'VECTOR', 'GIN', 'BITMAP', 'NGRAMBF'}

ALTER TABLE ... ADD INDEX idx_detalle_inv (detalle) USING GIN;
  -> ERROR 1064: GIN does not support replicated mode.

The table carries "replicated_storage" = "true", the default in this build, and GIN — the inverted index — refuses to coexist with it. A third probe confirms what the engine expects at query time:

SELECT COUNT(*) FROM contratos WHERE detalle MATCH 'computadores';
  -> ERROR 1064: Match can only used as a pushdown predicate
     on column with GIN in a single query.: BE:10001

Producing a twin would mean recreating the table with replicated_storage = false, reloading 1.31 M rows and re-running every measurement — which invalidates the numbers already taken. That was not done, and this annex reports an absence rather than a comparison.

10 What these numbers do not say

11 Gate

Gate met

Complete CSV with engine, query, run, milliseconds, rows and checksum; identical checksums on the three comparable queries; a stored profile for Q1 and Q4 on both engines; the annex labelled non-comparable and kept out of the results table; every claim in this report traceable to a line in results/phase5/ or sql/0*_*.out.txt.