Urgent.News

600+ sources. One page. See who else covered it.

Editions

Tech

Putting a 200-Table Schema Into a Prompt

A 200-table schema does not fit usefully in a prompt, even when it fits in the context window. The design that works is a two-stage one — a cheap call that picks the tables, a second call that sees only those tables in full — and a read-only guarantee that lives in the database rather than in the prompt. The arithmetic that forces the design Start by counting rather than guessing. Take a schema…

A two-stage prompt design is recommended for handling a 200-table schema. In the first stage, create a catalogue of the tables, including their names, column names, types, and foreign keys, but exclude any constraints, indexes, or trailing clauses. This catalogue should be roughly 5,000 tokens in length. In the second stage, given a question, identify the smallest set of tables required to answer it, along with any additional tables needed for joining.

This catalogue-based approach is more efficient than sending the full schema every time, which would result in 16,000 tokens of near-uniform text competing with the actual question for the model's attention. The catalogue is stored alongside migrations in the repository and should be updated whenever the schema changes, as it becomes stale when the schema evolves.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Structured Data That Machines Read

Structured data is the one place where you tell a machine what your page means rather than hoping it infers it. It is also where honest sites quietly stop being honest, and where a mechanical detail…

Schema Versioning When Your Extraction Changes

The schema you shipped in March is not the schema you will want in September. Unlike a database migration, some changes to an extraction schema cannot be applied to existing rows by any transform, and…

More from Wednesday 12 August →