← Status board  /  Phase 0

Phase 0 — Schema discovery on the SECOP source Read-only investigation of 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.

Status complete Source MySQL 8.0.46 · pidecerca-prod Access SSH + local socket, read-only Rows 17,008,273 Next Phase 1 · Docker

1 Summary

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.

Columns discovered
85 + 96
brief named 4 + 3
Rows verified
11,120,877
and 5,887,396 — exact match
Reference counts
3 / 3
third one needed an operator fix
Scan throughput
122 MB/s
87 MB/s on SECOP II

Findings that change the plan

  1. The contract value is numeric, not text. 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.
  2. The brief's third reference count came from FULLTEXT, not LIKE. The same question returns 23,372, 23,883 or 5,358 depending on the operator. This is now the strongest argument for keeping the two text queries (Q2a/Q2b) in separate tables.
  3. SECOP I has no real date column. 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.
  4. 10.4% of SECOP I has no year at all, and 423,466 SECOP II rows have no fecha_firma. A year-partitioned model without an explicit "unknown" partition would silently drop 1.6 M rows from every date-filtered query.
  5. Year-based subsetting does not fit the 4 GB budget. A single recent SECOP II year is 2.2–2.5 GB of CSV on its own. The subset therefore uses deterministic modulo sampling, and partitioning becomes a modelling decision rather than the sampling mechanism.
Do not trust these statistics

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.

Blockers closed

B3 — value column: closed, numeric.

B1 — access: resolved via SSH key + local socket; port 3306 stays closed to the internet.

2 Method and read-only guarantees

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.

ControlHow it was enforced
TransportSSH 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.
CredentialsNo database password was used or stored: access is root@localhost through the socket, invoked per query.
No writesNo INSERT, UPDATE, DELETE, DDL or ANALYZE was issued. Nothing was installed on the server.
Key handlingWindows 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 controlFull scans were run sequentially, never in parallel, and each one's duration was measured — the cost is part of the evidence, not an accident.
Known deviation

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.

3 Server profile

MySQL version8.0.46-0ubuntu0.24.04.5 (Linux, aarch64)
Hostpidecerca-prod · 129.80.141.192
Listening address127.0.0.1:3306 and 127.0.0.1:33060 only
Charset / collationutf8mb4 / utf8mb4_0900_ai_ci — case- and accent-insensitive
InnoDB buffer pool3.0 GB
Databasesinformation_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.

4 Objects and physical size

ObjectRows (COUNT(*)).ibd fileNote
secop_i_records11,120,87726.83 GBmatches the brief exactly
secop_ii_registros5,887,39616.27 GBmatches the brief exactly
Schema total—≈ 46.7 GiB94 objects

Two discrepancies, both recorded

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.

Why this matters for the subset

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.

5 Column inventory

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.

Value columns — blocker B3 closed

TableNumeric value columns (all double)
secop_i_recordsCuantia_Proceso, Cuantia_Contrato, Valor_Total_de_Adiciones, Valor_Contrato_con_Adiciones, Valor_Rubro
secop_ii_registrosvalor_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.

Date columns — this drives partitioning

TableColumnTypeAssessment
secop_ii_registrosfecha_firmadateUsable native year partitioning
secop_ii_registrosfecha_inicio_contrato, fecha_fin_contratodateUsable alternative ranges
secop_i_recordsFecha_de_Firma_del_ContratotextNot a date free text
secop_i_recordsAnno_Firma_del_Contratovarchar(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.

Text columns behind Q2

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.

6 Indexes

SECOP I — 4 FULLTEXT, as documented

IndexColumn
ft_detalle_objeto_contratarDetalle_del_Objeto_a_Contratar
ft_nom_raz_social_contratistaNom_Raz_Social_Contratista
ft_nombre_entidad_secop1Nombre_de_la_Entidad
ft_nombre_represen_legalNombre_del_Represen_Legal
PRIMARYUID — clustered point lookup for Q3

Plus five composite BTREE on territory codes and two on Numero_de_Proceso / Numero_del_Contrato.

SECOP II — 7 FULLTEXT, also as documented

IndexColumn
ft_objeto_contratoobjeto_contrato
ft_descripcion_procesodescripcion_proceso
ft_nombre_entidadnombre_entidad
ft_proveedor_adjudicadoproveedor_adjudicado
ft_nombre_representantenombre_representante_legal
ft_condiciones_entregacondiciones_entrega
ft_descripcion_documentos_tipodescripcion_documentos_tipo
PRIMARYid_contrato (NOT NULL) — clustered key

Plus eight composite BTREE, including (nit_entidad_n, fecha_firma).

Neither table is partitioned

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.

7 Validation counts — and the 511-row discrepancy

ProbeMeasuredBriefΔElapsed
bogota in Nombre_de_la_Entidad667,388667,3880219.2 s
bogota in nombre_entidad (II)70,94170,9410187.6 s
computadores in Detalle_del_Objeto_a_Contratar23,88323,372+511223.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.

OperatorCountWhat it actually means
MATCH … AGAINST('computadores' IN BOOLEAN MODE)23,372FULLTEXT word match — this is the brief's number
LIKE '%computadores%' (ai_ci)23,883substring match, case- and accent-insensitive
LIKE BINARY '%computadores%'5,358substring, 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.

Consequence for the report

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.

8 Year distribution

SECOP I — LEFT(Anno_Firma_del_Contrato,4)

Full scan, 224 s.

YearRowsShare
20171,177,661
(blank/NULL)1,152,071
20191,142,037
20161,070,124
20181,050,188
2020918,805
2015907,054
2021896,136
2014776,302
2013607,337
2012455,450
2022433,313
2004–2010333,985
2011198,179

SECOP II — YEAR(fecha_firma)

Index-served, 5 s.

YearRowsShare
20251,041,083
2024935,116
2023841,348
2022709,916
2026708,952
2021561,336
(NULL)423,466
2020357,109
2018142,909
2019142,556
201722,253
2015–20161,352
1.58 M rows have no date

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.

9 Value quality

Cuantia_Contrato on SECOP I, one full scan (267 s):

Rows
11,120,877
no filtering applied
NULL
0
every row carries a value
Zero
1.22 M
10.9% of rows
Maximum
3.64e14
outlier, not a contract

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.

10 Throughput baseline

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.

ScanBytes touchedElapsedEffective rate
bogota · SECOP I26.83 GB219.2 s122 MB/s
bogota · SECOP II16.27 GB187.6 s87 MB/s
computadores · SECOP I26.83 GB223.8 s120 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.

11 Subset decision

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.

MetricExpected in subsetThresholdMargin
secop_i_records rows855,452——
secop_ii_registros rows452,877——
Total rows1,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

Why year slicing was rejected

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.

Consequence to accept explicitly

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.

12 Decisions and open items

DecisionStatus
Value column (B3)Closed double, no separators
Access route (B1)Closed SSH + local socket
Reference countsValidated 3 / 3
Partition designDecided native II · derived I
Subset strategyProposed k = 13, awaiting approval
StarRocks version + digestOpen 3.5.x proposed
Open itemImpact
SUB_PART of BTREE on text columnsLow
Confirm the two *_mv are the only extra objectsLow
Subset approvalBlocking F4
Image pinBlocking F1

13 Evidence and reproduction

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.

FileContents
sql/00_discover.sqlRead-only discovery script: server profile, databases, sizes, columns, indexes, partitions, value-column heuristic.
sql/00_discover.out.txtIts raw output — 85 + 96 columns, 47 index rows, 4 + 7 FULLTEXT.
sql/00_reference_counts.txtThe three reference counts with per-scan elapsed time.
sql/01_diagnostics.shOperator comparison, year distributions, value-quality scan.
sql/01_diagnostics.out.txtRaw diagnostics output.
docs/schema-notes.mdSame findings in markdown, for whoever works from the repo rather than the browser.
Reproduction

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.