1 / 8

PostgreSQL ยท SQL foundations

Make the type match the meaning

Types are part of the data model. Use text for ordinary strings unless a real length limit is part of the rule; varchar(n) enforces a limit but offers no general performance advantage over text. Use integer for ordinary counts and bigint when the range may exceed about 2.1 billion. Use numeric for exact decimal amounts such as currency, not binary floating point.

An event that happened at a moment in time is usually timestamptz. PostgreSQL stores that instant in UTC and displays it using the session time zone. It does not preserve the originally supplied time-zone label. A timestamp without time zone is just a wall-clock date and time.