Description
compile_insert (src/codegen/stmt/insert.rs:200) and compile_update_with_catalog (src/codegen/stmt/update.rs:80) both call parse_create_table(&schema.sql) on every single statement compile, re-tokenizing and re-parsing the table's full original CREATE TABLE text purely to recover constraint info (CHECK, PRIMARY KEY/AUTOINCREMENT) that TableSchema doesn't store structurally. This runs once per INSERT/UPDATE compile — i.e., once per single-row statement — and is a likely major contributor to a ~10x perf gap vs. the SQLite oracle on single-row insert/update benchmarks (insert_single: 14.9ms ours vs 1.85ms oracle).
Found via a 4-agent investigation into tests/performance/crud.rs/engine.rs benchmark regressions. Fsync frequency and journal discipline were separately ruled out as correct (matching SQLite's own 2-fsync-per-commit rollback-journal model).
Complexity
Estimate: small
Reasoning: Add a constraints/rowid-alias-autoincrement field to TableSchema (src/schema/ddl_reader.rs:71), populate it once in read_schema, and switch the two call sites to read it directly instead of re-parsing. Contained to schema loading + two codegen call sites; no grammar/parser surface change.
Context
Related to the tokenizer string-copy ticket (filed alongside this one) — the two compound, since each DDL re-parse also pays a full tokenizer string allocation.
Acceptance Criteria
Description
compile_insert(src/codegen/stmt/insert.rs:200) andcompile_update_with_catalog(src/codegen/stmt/update.rs:80) both callparse_create_table(&schema.sql)on every single statement compile, re-tokenizing and re-parsing the table's full originalCREATE TABLEtext purely to recover constraint info (CHECK, PRIMARY KEY/AUTOINCREMENT) thatTableSchemadoesn't store structurally. This runs once per INSERT/UPDATE compile — i.e., once per single-row statement — and is a likely major contributor to a ~10x perf gap vs. the SQLite oracle on single-row insert/update benchmarks (insert_single: 14.9ms ours vs 1.85ms oracle).Found via a 4-agent investigation into
tests/performance/crud.rs/engine.rsbenchmark regressions. Fsync frequency and journal discipline were separately ruled out as correct (matching SQLite's own 2-fsync-per-commit rollback-journal model).Complexity
Estimate: small
Reasoning: Add a
constraints/rowid-alias-autoincrement field toTableSchema(src/schema/ddl_reader.rs:71), populate it once inread_schema, and switch the two call sites to read it directly instead of re-parsing. Contained to schema loading + two codegen call sites; no grammar/parser surface change.Context
Related to the tokenizer string-copy ticket (filed alongside this one) — the two compound, since each DDL re-parse also pays a full tokenizer string allocation.
Acceptance Criteria
TableSchemacarries parsed constraint/autoincrement metadata populated atread_schematimecompile_insert/compile_update_with_catalogno longer callparse_create_table(&schema.sql)per statementinsert_single/update_pkbenchmarks intests/performance/crud.rsshow measurable improvement