The Surprising Impact of Medium-Size Texts on PostgreSQL Performance

published on 2023/09/28

Any database schema is likely to have plenty of text fields. In this article, I divide text fields into three categories:

  • Small texts: names, slugs, usernames, emails, etc. These are text fields that usually have some low size limit, maybe even using varchar(n) and not text.

  • Large texts: blog post content, articles, HTML content etc. These are large pieces of free, unrestricted text that is stored in the database.

  • Medium texts: descriptions, comments, product reviews, stack traces etc. These are any text field that is between the small and the large. These type of texts would normally be unrestricted, but naturally smaller than the large texts.

In this article I demonstrate the surprising impact of medium-size texts on query performance in PostgreSQL.

Hakibenita