How do I find duplicate rows in a large table?
Count rows per key and look for counts above one. Your AI groups by the id column, counts, and sorts the counts descending: any id with a count of 2 or more is duplicated. On a very large table, check a slice at a time (a month, a load): each query stays small. The demo has a few duplicate orders on purpose.
Steps
- Connect your assistant to the public demo. It's a read-only instance with 10 million synthetic orders,
so you can try this before you have your own. In Claude Code:
claude mcp add --transport http mcpdata-demo https://demo.mcpdata.org/mcp --header "Authorization: Bearer cdb_live_PkVoldus8qcE-hqffjajNZzQwiA7rTHMoR4RLSAxsCE"
The key is public on purpose: it can only read the demo's sample data. For Claude Desktop, Cursor and other apps, see Connect your AI.
- Ask your question. Give your AI this prompt:
Using mcpdata, are there duplicate order_id values in Demo.Orders for June 2025? Show the ones with the most copies.
| order_id | copies |
|---|---|
| 7651969 | 2 |
| 7820143 | 2 |
| 7741920 | 2 |
| 7784482 | 2 |
| 7638720 | 2 |
| 7627256 | 2 |
| 7807978 | 2 |
| 7831625 | 2 |
| 7921526 | 2 |
| 7658647 | 2 |
Synthetic data: the demo's orders are generated, not real customers.
The assistant needs mcpdata connected (step 1) to run the query.
Why this works
Spotting duplicates needs every row of the slice you check, because the two copies can be far apart. A count per key in the database checks them all at once; the AI only sees the handful of keys that repeat. A key-per-row count over a whole 10-million-row table makes 10 million groups, which is more working memory than a small shared instance has; the database stops such a query with a clear message instead of failing, so ask for one month (or one load) at a time, or run it on a dedicated instance.