IT lexicon › Database › Collation

Collation

Database På svenska → Updated: 2026-07-29

The rules for how text is compared and sorted. It determines what ORDER BY returns, the order an index is stored in and whether 'A' = 'a'. It depends on language, not on the characters themselves.

Swedish sorts å, ä and ö at the end of the alphabet; German treats ä as a with dots and sorts accordingly. Same data, different order, both correct. The trap is that indexes are stored in collation order — change the rules underneath the database and the index becomes wrong with no warning. That happened for real when glibc 2.28 changed its rules and an upgraded Linux distribution could leave PostgreSQL with corrupt indexes and duplicates in unique columns. Hence the current recommendation to use ICU collations with version tracking. The C collation compares raw bytes, is fastest and always stable — but sorts words like a computer, not like a person.

← Back to the lexicon