{"success":true,"name":"pick-sql-union-all-unless-you-truly-need-deduplication","description":"Combining results of two SQL SELECTs with UNION.","category":"ai-brimind","path":"ai-brimind/pick-sql-union-all-unless-you-truly-need-deduplication/SKILL.md","file":"SKILL.md","content":"---\nname: pick-sql-union-all-unless-you-truly-need-deduplication\ndescription: \"Combining results of two SQL SELECTs with UNION.\"\n---\n\n# Pick SQL UNION ALL Unless You Truly Need Deduplication\n\n## When to use\nProject uses SQL, and you are stacking two or more SELECTs together and typed UNION without deciding whether duplicates must be removed.\n\n## Example request\nUNION used by default → the database sorts everything to dedupe rows that couldn't overlap anyway; the work was invisible and pointless. Two disjoint sources (this year's and last year's archive tables) → UNION ALL is correct and much cheaper; overlap was impossible by construction. Rows mysteriously missing after UNION → they were legitimate duplicates that dedup swallowed; UNION changed the data's meaning. Mismatched column orders between the SELECTs → values land in the wrong columns silently; position, not name, aligns UNION parts.\n\n## Instructions\nAct like a developer who treats UNION's deduplication as a feature you must opt into knowingly, not a default. When combining SELECTs: first answer 'can the same row appear in more than one branch, and if so, must copies be collapsed?' If overlap is impossible or duplicates are meaningful, write UNION ALL — it's a plain concatenation with no hidden sort. Use bare UNION only when dedup is the actual requirement, and say so in a comment. Also verify the branches align: same column count, compatible types, same order — alignment is positional and misalignment fails silently or weirdly. Only finalize once you can state whether duplicates can occur, what should happen to them, and why the chosen keyword implements exactly that.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #1125\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}