Skip to content

Instantly share code, notes, and snippets.

View LautaroJayat's full-sized avatar
💭
👽

Lautaro Jayat LautaroJayat

💭
👽
View GitHub Profile
@rraval
rraval / postgres-collation.md
Last active December 6, 2023 16:25
PostgreSQL collation is a massive footgun

This is a slightly stripped down version from our internal bug tracker. The point of posting this publicly is part FYI, part peer review. I'm hoping someone can look at this, disagree, and tell me all the downsides of using the C locale or point out things I've misunderstood. The Recommendations section in particular is contextualized by our database serving a SaaS product for users from many different locales, thus making locale a render level concern. YMMV, caveat emptor, etc.


Collation defines the character ordering for textual data. For Postgres, https://www.postgresql.org/docs/current/static/locale.html:

The locale settings influence the following SQL features:

  • Sort order in queries using ORDER BY or the standard comparison operators on textual data
  • The upper, lower, and initcap functions