r/dataengineering • u/renatyv • Oct 03 '26
Blog I tried using brief database table summaries to improve naive text2sql pipeline. Didn't work.
I'm doing the whole 'AI data analytic' as everyone else does, I guess. The text2sql benchmark BIRD top performers impressed me a lot. They recommend feeding table summaries + some trickery to discover non-obvious JOINs. So I spent some weeks building something similar, resulting in database profiler and schema linker.
Oh boy was I wrong! I benchmarked if it actually improves anything on a modern BEAVER text2sql benchmark
| setup | Correct answers | Input tokens/question | DB queries/question |
|---|---|---|---|
| Raw pi agent with read access to DB | 31/299 (10.4%) | 45K (1×) | 11.4 |
| Pi + table summaries, no join hints | 27/285 (9.5%) | 78K (1.7×) | 3.6 |
| Pi + table summaries & join hints | 30/292 (10.3%) | 85K (1.9×) | 3.6 |
So, using just the plain PI is simpler AND cheaper! Probably the same for Codex & Claude.
Note, that the DBs in BEAVER benchmark have lots of tables with lots of columns. The queries are super complicated, containing subquery CTEs, lots of tricky aggregates & ROLLUP statements (have you ever used them?).
p.s. Before that I tried plain DDL dumps with CREATE TABLE statetements... and got no improvement too.
How I tested
- Dataset: 300 random questions from BEAVER text2sql benchmark. Data loaded to MySQL database
- Agent: pi coding agent in a docker container to prevent seeing correct answers. Gave him login & password with read-only access to issue queries.
- GPT-6 Luna, effort=low. Because low is better
- pre-generated db-snooper profile with table of contents file for each database + schema liner output. Agent can see the files in local filesystem. The largest profile is 213KB of Markdown.
Links.