data-infra
Glossary ↗Data Deduplication
Data deduplication ("dedup") is the process of identifying and removing, merging, or flagging duplicate records within a dataset — whether exact duplicates (byte-for-byte identical rows or files) or near-duplicates (semantically or structurally similar but not identical content). Why it matters for AI/SaaS builders: duplicate data quietly degrades AI product quality in a specific and expensive way — if a RAG pipeline ingests the same document twice (a common outcome of a naive re-sync job that doesn't check for existing records), retrieval results get flooded with redundant near-identical chunks, crowding out genuinely diverse relevant results within a limited top-k window, and the team pays to embed and store the same content multiple times for no benefit. In data pipelines generally, deduplication is also what prevents a retried or re-run job from double-counting the same event in an analytics aggregation, which is closely related to (and often solved by the same mechanism as) idempotency. How it works: exact-duplicate detection is comparatively simple — hash the content (e.g., a SHA-256 of the raw text or file bytes) and check whether that hash already exists before inserting, an approach cheap enough to run on every ingest. Near-duplicate detection is harder and more AI-specific: comparing embedding cosine similarity between a new document and existing ones, flagging pairs above a high threshold (e.g., >0.97) as likely duplicates or revisions of the same underlying content, since exact-hash matching misses a document that's identical except for a timestamp in the header or minor reformatting. At the pipeline level, deduplication is often implemented via an idempotency-key-style unique constraint on a natural identifier (a source document's external ID, a webhook event ID) so re-processing the same source never creates a second copy. Worked example: a knowledge-base AI SaaS syncs documents nightly from a customer's Confluence instance. Without deduplication, a page that gets re-exported with a slightly different internal timestamp each night would be re-ingested and re-embedded every single night, bloating the vector store with hundreds of near-identical versions of the same page and degrading search relevance. The fix: the sync job hashes each page's content (ignoring volatile metadata like timestamps) and only re-embeds a page when its content hash actually changes from the last sync, cutting both storage growth and embedding API cost dramatically while keeping the vector store clean. The same content-hash check also powers a secondary benefit: when a page's hash does change, the diff between old and new content tells the team exactly which documents were actually edited that day, which is useful signal for a "what changed recently" feature layered on top of the knowledge base later.
Related terms