← Status board  /  Phase 2

Phase 2 — Subset design and verification 35.86 GB of payload will not fit twice inside two 4 GiB containers. This phase decides how to cut it, proves the cut is not biased, and records what the cut costs in exchange.

Status complete · approved Method CRC32 modulo, k = 13 Rows 1,309,594 On disk 0.69 GB Next Phase 3 · DDL

1 Summary

The full source is 35.86 GB of payload across two tables. Both engines run under a 4 GiB ceiling, and the benchmark requires warm cache on both sides — so the working set has to be roughly an eighth of the source, and it has to be cut the same way in both tables or Q1 and Q2 stop being comparable.

Source payload
35.9 GB
21.89 + 13.97 GB · 43.10 GB of .ibd
Sampling
k = 13
CRC32(hash key) % 13 = 0
Rows kept
1,309,594
856,422 + 453,172 · 7.70 % of source
Hash uniformity
7.72 %
measured vs 7.692 % expected
Decision

Keep the rows where CRC32(UID) % 13 = 0 for SECOP I and CRC32(id_contrato) % 13 = 0 for SECOP II. Approved by the reviewer on 2026-11-25 and frozen in sql/03_export_spec.sql.

2 The budget the subset has to fit

The constraint is not disk — it is that a benchmark run must find the data in memory. A run sequence that spills to disk by the third iteration measures the page cache, not the engine.

ConstraintValueEffect on the subset
Container ceiling, each engine4 GiBHard upper bound; exceed it and the container is killed, not slowed.
MySQL buffer pool1 GiBThe row store must fit in roughly 1 GB or every scan becomes a disk read.
StarRocks working memory< 4 GiBCompressed columnar data plus aggregation state for Q1 and Q4.
Target subset size≈ 0.7 GBChosen so the text fits inside 1 GB uncompressed and compresses well below it.

One thirteenth of 35.86 GB is 2.76 GB of payload — which is why the estimate was written down as ≈2.7 GB here and later measured at 0.69 GB. Section 7 explains the gap; it was my error, not a property of the data.

3 Options considered

Three ways to cut were on the table. Two were rejected with measurements, not preferences.

OptionVerdictReason
Year slicing (one or two years)RejectedA single recent SECOP II year is 2.2–2.5 GB of CSV and 2023 alone is 2.0 GB — three to four times the budget, before indexes. It also destroys the point of the exercise: the queries are about entities and text across years, and one year makes every aggregation smaller than the data it summarises.
Row-limit sampling (LIMIT n)RejectedWithout ORDER BY it inherits physical order, which correlates with load date and therefore with year. The subset would be a biased slice wearing a random label.
Hash modulo samplingChosenDeterministic, reproducible with one predicate, independent of physical order, and applies identically to both tables.

Why not 1 in 10, or 1 in 20

The measured export is 0.69 GB at k = 13, so the same data at k = 10 would be ≈0.90 GB of TSV — and MySQL still has to build the FULLTEXT index over it inside the 1 GB buffer pool. That is the point where the row store starts paging and the comparison stops being about the engine.

k = 20 would shrink to ≈0.45 GB, but it thins the text Q2 searches: the narrowest reference query would return about 1,194 rows (23,883 ÷ 20) instead of 1,837, and a single-digit percentage difference in the answer stops being measurable. k = 13 is the largest divisor that still fits the memory and the smallest that keeps the text population dense enough.

4 The method, exactly

One predicate, applied on the server side during export, with no ORDER BY, so neither engine ever sees a sorted subset.

-- SECOP I
WHERE CRC32(UID) % 13 = 0

-- SECOP II
WHERE CRC32(id_contrato) % 13 = 0

Both keys are immutable identifiers, not business values, so the selection cannot correlate with entity size, contract value or year. That is the property that makes the subset defensible: a biased sample is worse than a small one, because it turns every later number into an artefact of the bias.

Expected vs obtained

Expected from the source counts: 855,452 (SECOP I) + 452,877 (SECOP II) = 1,308,329.

Obtained: 856,422 + 453,172 = 1,309,594 — +0.11 % and +0.07 % over expectation, which is what a hash over 17 million rows looks like. The expectation is an average, not a quota.

5 The five checks

The subset had to pass five checks before the export was allowed to run. The third one could only be completed after the load, which is why Phase 4 re-runs it against real tables.

#CheckMeasuredResult
1Source COUNT(*) under the same predicate equals the lines written856,422 / 453,172Pass The export aborts on any mismatch, so a truncated file cannot reach the load.
2Hash uniformity on a random sample15,434 of 200,000Pass 7.72 % against an expected 7.692 %; no bucket is starved.
3Three reference counts, scaled by 1/1351,338 / 5,457 / 1,837Pass Verified after the load at +0.40 %, −0.24 % and +0.60 % — inside the ±1 % tolerance. Detail in Phase 4.
4Year distribution resembles the sourcesee belowPass No year is over- or under-represented by more than sampling noise.
5Rows without a usable date are preserved, not dropped120,778Pass They land in anio = 0, which is why the DDL needs an explicit unknown partition.

Check 4 in numbers

Every year in the subset is within 0.5 % of the full-source count divided by 13. Spot values after the load:

YearRows in the subsetFull source / 13
0 (no date)120,778120,778 — the null markers, exactly
202364,99564,719
202471,90171,932
202580,12680,083

6 What the cut costs — stated, not hidden

A sampled subset buys memory headroom and pays for it in three places. All three are disclosed in the report rather than absorbed into the conclusions.

Partitions stop being the sampling mechanism

Because the subset is spread across all 25 year partitions, a query that filters by year reads a slice of every partition's data rather than one year's worth. Partition pruning is therefore demonstrated as a plan property (partitions=1/25), not claimed as the reason StarRocks is faster.

Absolute times are not production times

Every figure in Phase 5 is 1/13 of the source. The comparison is between engines on the same rows; it is not a prediction of how long the query would take on all 17 million.

Rare values get thinner

A term that appears 20 times in the source appears once or twice here, and a query that returns 3 rows is dominated by planning overhead on both engines. This is why the query set uses terms with thousands of hits and why the narrowest reference query still has 1,837 rows.

Note on the 511 rows

The brief's figure of 23,372 for computadores did not reproduce: the same question gives 23,372 with MATCH…AGAINST, 23,883 with LIKE and 5,358 with LIKE BINARY. The subset check uses the LIKE figure scaled by 13, and the three operators stay separate queries in Phase 5.

7 The size estimate that was wrong

In this phase I estimated the export at ≈2.7 GB, derived from .ibd size divided by row count and multiplied by the subset rows. The measured export is 0.69 GB — 3.9× smaller. The reason is that .ibd carries the four and seven FULLTEXT trees plus page padding, none of which is in a TSV of the same rows. Measured 528 bytes per row, not 2.06 KB.

It is recorded because it was visible on the status board and in this report before the measurement existed. An estimate that turned out optimistic is a normal part of the method; an estimate quietly deleted afterwards is not.

8 Gate

Gate met

A decision table with rows, GB, the three reference counts and the applied fraction exists, passes all five checks, and was signed off by the reviewer on 2026-11-25. The predicate is frozen in sql/03_export_spec.sql; the export in Phase 4 uses exactly that file.

9 Evidence