professional-programming/antipatterns/database-antipatterns.md
2020-07-21 09:37:15 +02:00

1.1 KiB
Raw Blame History

Table of Contents

Database anti-patterns

Using VARCHAR instead of TEXT (PostgreSQL)

Unless you absolutely restrict the width of a text column for data consistency reason, dont do it.

This benchmark shows that theres fundamentally no difference in performance between char(n), varchar(n), varchar and text. Heres why you should pick text:

  • char(n): takes more space than necessary when dealing with values shorter than n.
  • varchar(n): its difficult to change the width.
  • varchar is just like text.
  • text does not have the width problem that char(n) and varchar(n) and has a cleaner name than varchar.