## TL;DR

Scanning 100,000 vendors per receipt is too slow. Index the vendor list (normalized-name lookup plus fuzzy matching on candidates), batch the lookups, and cache results so repeat merchants resolve instantly.

## Error

```text
agent's vendor matcher failed with timeout on 100k vendor list
```

## Steps

1. Build a normalized index: lowercase, strip punctuation and legal suffixes from every vendor name. Expected: a lookup structure keyed by normalized name.
2. For each receipt merchant, do an exact normalized lookup first. Expected: most merchants resolve in constant time.
3. For misses, fuzzy-match against a candidate subset (same first letter, similar length) rather than the whole list. Expected: fuzzy search stays fast.
4. Cache every resolved merchant-to-vendor mapping. Expected: repeat merchants never hit the matcher twice.
5. Refresh the index on a schedule as the vendor list changes. Expected: the index stays current without rebuilding per run.

## When to use

- Vendor matching times out on large vendor lists.
- The matcher does a full scan per receipt.

## When not to use

- The matcher picks the wrong vendor quickly (a scoring problem, not speed).
- The vendor list is small (the timeout has another cause).

## Tool compatibility

- Custom vendor-matching in audit agents; large ERP vendor masters.

## Variant phrasings

### Vendor lookup timed out

Same failure, shorter wording.

### Matcher too slow on vendor database

The performance phrasing of the same problem.

## Why it happens

Linear scans multiply: 100k vendors times thousands of receipts is billions of comparisons. Indexing turns each lookup from a scan into a direct hit.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_X2V0EvXWz7KSRMCcrO5JSw
