Running an LLM over your existing data: backfills and bulk jobs without surprises
How to run an AI feature over thousands of existing records: estimating cost, testing on a sample, building resumable jobs, handling failures and rate limits, and checking quality before results reach users.
Most AI features are designed for new data: a new ticket, a new upload, a new message. Then someone asks the obvious question. Can we run it on everything we already have? Every old ticket classified, every past document summarised, every product description rewritten.
A backfill looks like a loop around a function you’ve already built. In practice, it’s where cost estimates go wrong, rate limits bite and a small prompt mistake gets repeated across your whole database. Here’s how we’d run an LLM over existing data without surprises.
Decide whether you need it all
- Ask what the results are for. If people only look at recent records, you may only need to process the last few months.
- Process on demand where possible, such as summarising an old document the first time someone opens it, rather than processing everything up front.
- Prioritise: active customers, open items or high-value records first, the long tail later or never.
Estimate cost and time before you start
- Measure on a real sample: average input size, output size and time per item.
- Multiply out honestly, including retries and the cost of re-running if you change the prompt halfway. Our post on what an AI feature costs to run shows how.
- Check your provider’s rate limits against how fast you need to finish, and plan the job to stay well within them.
- Look for cheaper routes, such as a smaller model for simple tasks or your provider’s batch processing options, and test that quality holds before switching. See choosing an LLM for your product.
Test on a sample first
A bulk job multiplies mistakes as efficiently as it multiplies results.
- Run a few hundred items first, chosen to include old formats, empty fields, very long records and other languages.
- Review the results by hand, not just the error count. Old data often looks different from what the feature was built for.
- Fix the prompt and validation before going further. Our post on test your LLM feature before users do covers building a test set from samples like these.
Build the job to be stopped and resumed
Long jobs get interrupted: deploys, provider outages, a bug you spot halfway through.
- Track status per record: pending, done, failed, with the time and attempt count.
- Make each item safe to run twice, so restarting never creates duplicates.
- Process in small batches with a configurable rate, so you can slow down without stopping.
- Store results with the prompt version and model, so you know which records need re-running after a change.
- Run it in your background job system, on its own queue, so it never slows down the live product. Our post on adding AI to an existing SaaS app covers the setup.
Handle failures without losing your place
- Retry temporary errors with backoff, and give up after a few attempts.
- Validate every result before saving it, and mark invalid ones as failed rather than storing them. See getting reliable JSON from an LLM.
- Collect failures for review instead of letting them stop the job.
- Set a spending limit that pauses the job automatically.
Check quality before users see results
- Write results somewhere separate first, or behind a flag, rather than overwriting the fields people use today.
- Sample results across the run, not just the start, in case quality changes with older data.
- Release gradually and keep the ability to roll back. Our post on rolling out AI features safely walks through it.
The short checklist
- Decide what actually needs processing and prioritise
- Estimate cost and time from a real sample, within rate limits
- Test on a few hundred varied items and review by hand
- Track status per record and make items safe to re-run
- Validate results, collect failures and set a spending limit
- Write results separately and release gradually
If you have years of data you want to put an AI feature to work on, see our fixed-scope offers or book a 30-minute call.