secop_i_ii_integrado: real columns, indexes, row counts, reference validation, year distribution, value quality and the subset decision. Every figure here was measured on 2026-11-25; nothing is copied from the brief unless it was reproduced.
Phase 0 asked one question — what is actually in these two tables — and answered it well enough to design the whole lab on top of it. It also killed one blocker, corrected one number in the brief, and produced a first measurement of how fast this server scans.
Cuantia_Contrato and valor_contrato are double. Blocker B3 is closed: no thousands separators, no cleaning function, no risk of biasing the benchmark with engine-specific string handling.Fecha_de_Firma_del_Contrato is text; Anno_Firma_del_Contrato is varchar(1024). Year partition on SECOP I needs a derived integer, while SECOP II has a clean fecha_firma DATE.fecha_firma. A year-partitioned model without an explicit "unknown" partition would silently drop 1.6 M rows from every date-filtered query.information_schema.TABLES reports 411,423 rows and 445 MB for a schema that holds 17 M rows and ~47 GiB. The tables were rebuilt this morning and the statistics were never refreshed.
Every count in this report comes from COUNT(*), never from TABLE_ROWS. The DDL comments will carry the same warning.
B3 — value column: closed, numeric.
B1 — access: resolved via SSH key + local socket; port 3306 stays closed to the internet.
The source server is production-adjacent and never becomes part of the lab. Every statement executed against it was a read: SELECT, SHOW, and queries against information_schema.
| Control | How it was enforced |
|---|---|
| Transport | SSH as ubuntu@pidecerca-prod; MySQL reached over the local socket, so port 3306 remains bound to 127.0.0.1 and nothing new is exposed. |
| Credentials | No database password was used or stored: access is root@localhost through the socket, invoked per query. |
| No writes | No INSERT, UPDATE, DELETE, DDL or ANALYZE was issued. Nothing was installed on the server. |
| Key handling | Windows rejects PEM files readable by BUILTIN\Users; the key was copied to a temp path with an ACL restricted to the local user. The original file was not modified and will be deleted with the temp copy. |
| Load control | Full scans were run sequentially, never in parallel, and each one's duration was measured — the cost is part of the evidence, not an accident. |
The first remote script began with a UTF-8 BOM, so bash reported set: command not found on line 1. Harmless: the functions and statements below it ran normally, and the measured results were unaffected.
| MySQL version | 8.0.46-0ubuntu0.24.04.5 (Linux, aarch64) |
| Host | pidecerca-prod · 129.80.141.192 |
| Listening address | 127.0.0.1:3306 and 127.0.0.1:33060 only |
| Charset / collation | utf8mb4 / utf8mb4_0900_ai_ci — case- and accent-insensitive |
| InnoDB buffer pool | 3.0 GB |
| Databases | information_schema, mysql, performance_schema, secop_i_ii_integrado, sys |
The 3 GB buffer pool is why the timings in §9 are meaningful: a 26.8 GB table cannot be cached, so a full scan is real physical I/O, every time.
| Object | Rows (COUNT(*)) | .ibd file | Note |
|---|---|---|---|
secop_i_records | 11,120,877 | 26.83 GB | matches the brief exactly |
secop_ii_registros | 5,887,396 | 16.27 GB | matches the brief exactly |
| Schema total | — | ≈ 46.7 GiB | 94 objects |
94 objects, not 93. The extras are materialised views: secop_global_municipio_contratista_mv (1.38 GB) and secop_global_municipio_representante_mv (1.05 GB). They are derived data and none of them carries source rows.
File size is not payload size. The brief's 21.89 GB and 13.97 GB describe data; the .ibd files are 26.83 GB and 16.27 GB because each FULLTEXT index lives in its own fts_*.ibd file and is counted in the directory listing.
Indexes do not travel in a CSV. The export budget tracks payload — roughly 1.97 KB per SECOP I row and 2.37 KB per SECOP II row — not the 43 GB of files. Sizing the subset against the file size would have made it four times too small.
secop_i_records has 85 columns; secop_ii_registros has 96. The seven columns named in the brief all exist — they are a subset, not the schema.
| Table | Numeric value columns (all double) |
|---|---|
secop_i_records | Cuantia_Proceso, Cuantia_Contrato, Valor_Total_de_Adiciones, Valor_Contrato_con_Adiciones, Valor_Rubro |
secop_ii_registros | valor_contrato, valor_pago_adelantado, valor_facturado, valor_pagado, valor_pendiente_pago, valor_amortizado, valor_pendiente_amortizacion, valor_pendiente_ejecucion, valor_facturado_total |
Consequence for Q1: SUM(Cuantia_Contrato) and SUM(valor_contrato) execute identically on both engines. No conversion, therefore no opportunity for one engine to win or lose on string parsing.
| Table | Column | Type | Assessment |
|---|---|---|---|
secop_ii_registros | fecha_firma | date | Usable native year partitioning |
secop_ii_registros | fecha_inicio_contrato, fecha_fin_contrato | date | Usable alternative ranges |
secop_i_records | Fecha_de_Firma_del_Contrato | text | Not a date free text |
secop_i_records | Anno_Firma_del_Contrato | varchar(1024) | Derived year as string; needs cast to integer |
Any derivation — casting the SECOP I year — will happen once, in the export, and be applied identically by both loads. It is documented as part of the model, not buried in a query.
Detalle_del_Objeto_a_Contratar, objeto_contrato, descripcion_proceso, condiciones_entrega and descripcion_documentos_tipo are all text, and all five carry a FULLTEXT index.
| Index | Column |
|---|---|
ft_detalle_objeto_contratar | Detalle_del_Objeto_a_Contratar |
ft_nom_raz_social_contratista | Nom_Raz_Social_Contratista |
ft_nombre_entidad_secop1 | Nombre_de_la_Entidad |
ft_nombre_represen_legal | Nombre_del_Represen_Legal |
PRIMARY | UID — clustered point lookup for Q3 |
Plus five composite BTREE on territory codes and two on Numero_de_Proceso / Numero_del_Contrato.
| Index | Column |
|---|---|
ft_objeto_contrato | objeto_contrato |
ft_descripcion_proceso | descripcion_proceso |
ft_nombre_entidad | nombre_entidad |
ft_proveedor_adjudicado | proveedor_adjudicado |
ft_nombre_representante | nombre_representante_legal |
ft_condiciones_entrega | condiciones_entrega |
ft_descripcion_documentos_tipo | descripcion_documentos_tipo |
PRIMARY | id_contrato (NOT NULL) — clustered key |
Plus eight composite BTREE, including (nit_entidad_n, fecha_firma).
PARTITION_COUNT = 1 on both. There is no pruning to inherit: partitioning in the lab is our design decision and its benefit must be demonstrated, not assumed.
| Probe | Measured | Brief | Δ | Elapsed |
|---|---|---|---|---|
bogota in Nombre_de_la_Entidad | 667,388 | 667,388 | 0 | 219.2 s |
bogota in nombre_entidad (II) | 70,941 | 70,941 | 0 | 187.6 s |
computadores in Detalle_del_Objeto_a_Contratar | 23,883 | 23,372 | +511 | 223.8 s |
2.19% is far outside the ±1% tolerance set for subset verification, so it was investigated rather than accepted. The resolution is not a data drift: it is three different operators answering the same business question.
| Operator | Count | What it actually means |
|---|---|---|
MATCH … AGAINST('computadores' IN BOOLEAN MODE) | 23,372 | FULLTEXT word match — this is the brief's number |
LIKE '%computadores%' (ai_ci) | 23,883 | substring match, case- and accent-insensitive |
LIKE BINARY '%computadores%' | 5,358 | substring, byte-exact — lower case only |
Root cause. A FULLTEXT index stores tokens. A word glued to punctuation, or to another word, is not indexed as the separate term computadores, so MATCH misses it while LIKE still finds the substring. Those rows are the +511.
Second fact, more useful. The 5,358 shows that the term appears capitalised ("Computadores") in roughly 78% of matches — a case-sensitive byte comparison collapses the count by 4.5×. Any text metric quoted without its operator and collation is meaningless.
This is precisely why Q2a (LIKE, identical on both engines) and Q2b (native FULLTEXT) are reported in separate tables. Mixing them would let either engine "win" a text query by changing the operator.
LEFT(Anno_Firma_del_Contrato,4)Full scan, 224 s.
| Year | Rows | Share |
|---|---|---|
| 2017 | 1,177,661 | |
| (blank/NULL) | 1,152,071 | |
| 2019 | 1,142,037 | |
| 2016 | 1,070,124 | |
| 2018 | 1,050,188 | |
| 2020 | 918,805 | |
| 2015 | 907,054 | |
| 2021 | 896,136 | |
| 2014 | 776,302 | |
| 2013 | 607,337 | |
| 2012 | 455,450 | |
| 2022 | 433,313 | |
| 2004–2010 | 333,985 | |
| 2011 | 198,179 |
YEAR(fecha_firma)Index-served, 5 s.
| Year | Rows | Share |
|---|---|---|
| 2025 | 1,041,083 | |
| 2024 | 935,116 | |
| 2023 | 841,348 | |
| 2022 | 709,916 | |
| 2026 | 708,952 | |
| 2021 | 561,336 | |
| (NULL) | 423,466 | |
| 2020 | 357,109 | |
| 2018 | 142,909 | |
| 2019 | 142,556 | |
| 2017 | 22,253 | |
| 2015–2016 | 1,352 |
1,152,071 SECOP I rows (10.4%) have no year, and 423,466 SECOP II rows have no fecha_firma. Without an explicit "unknown" partition, every date-filtered query silently excludes 9% of the corpus — a modelling bug that would look like a performance win.
Cuantia_Contrato on SECOP I, one full scan (267 s):
The maximum is three orders of magnitude beyond any plausible COP figure. It matters for Q1: one such row can dominate a SUM and make an engine look like it won on volume rather than on speed. Both engines read the same row, so the comparison stays fair — but the report must name the outlier, or Q1's result is not interpretable.
Three validation scans are also the first measurement of this server's scan rate with a 3 GB buffer pool — the bar StarRocks has to clear on equivalent hardware.
| Scan | Bytes touched | Elapsed | Effective rate |
|---|---|---|---|
bogota · SECOP I | 26.83 GB | 219.2 s | 122 MB/s |
bogota · SECOP II | 16.27 GB | 187.6 s | 87 MB/s |
computadores · SECOP I | 26.83 GB | 223.8 s | 120 MB/s |
SECOP II is slower per byte: wider rows and a varchar(255) predicate keep the CPU busier per page read. This asymmetry is worth keeping in mind when reading the benchmark — a query that scans SECOP II starts from a lower floor.
Recommendation: deterministic modulo sampling, k = 13 (7.69%). Not because it is more elegant than year slicing, but because year slicing does not fit in 4 GB on this corpus.
| Metric | Expected in subset | Threshold | Margin |
|---|---|---|---|
secop_i_records rows | 855,452 | — | — |
secop_ii_registros rows | 452,877 | — | — |
| Total rows | 1,308,329 | ≥ 1.2 M | +9% |
| CSV payload (estimated) | ≈ 2.7 GB | ≤ 3 GB | −10% |
bogota · SECOP I | ≈ 51,338 | ≥ 50,000 | +2.7% |
bogota · SECOP II | ≈ 5,457 | ≥ 5,000 | +9% |
computadores (LIKE) | ≈ 1,837 | ≥ 1,500 | +22% |
SECOP I : WHERE CRC32(UID) % 13 = 0 SECOP II : WHERE CRC32(id_contrato) % 13 = 0
A single recent SECOP II year is already 935k–1.04M rows, which is ≈2.2–2.5 GB of CSV; 2023 alone is 841k rows (≈2.0 GB). Adding any meaningful SECOP I slice pushes the export past the 3 GB ceiling. Half-year windows would fit, but they add within-year seasonality, and on SECOP I the date is free text — a range filter there cannot be trusted.
The year windows are too coarse for this corpus. That is a measurement result, not a preference.
The sample is uniform, not date-based. Year partitions still belong in the DDL — that is how such a table would really be built — but the pruning benefit is demonstrated with a year-filtered query over the sample. The partition key does not select the sample.
If a date-native sample is required instead, the container must grow to 6–8 GB and the plan gets rewritten around that.
| Decision | Status |
|---|---|
| Value column (B3) | Closed double, no separators |
| Access route (B1) | Closed SSH + local socket |
| Reference counts | Validated 3 / 3 |
| Partition design | Decided native II · derived I |
| Subset strategy | Proposed k = 13, awaiting approval |
| StarRocks version + digest | Open 3.5.x proposed |
| Open item | Impact |
|---|---|
SUB_PART of BTREE on text columns | Low |
Confirm the two *_mv are the only extra objects | Low |
| Subset approval | Blocking F4 |
| Image pin | Blocking F1 |
Every number above comes from one of these artifacts. They are kept in the repository so the report can be audited without access to the source.
| File | Contents |
|---|---|
sql/00_discover.sql | Read-only discovery script: server profile, databases, sizes, columns, indexes, partitions, value-column heuristic. |
sql/00_discover.out.txt | Its raw output — 85 + 96 columns, 47 index rows, 4 + 7 FULLTEXT. |
sql/00_reference_counts.txt | The three reference counts with per-scan elapsed time. |
sql/01_diagnostics.sh | Operator comparison, year distributions, value-quality scan. |
sql/01_diagnostics.out.txt | Raw diagnostics output. |
docs/schema-notes.md | Same findings in markdown, for whoever works from the repo rather than the browser. |
The discovery script is idempotent and read-only; running it again produces the same output unless the source changes. The two year distributions are the only expensive statements (224 s and 5 s), and the value-quality scan is 267 s. Total cost of re-running Phase 0: about 12 minutes of sequential full scans.