Data Type Picker

PostgreSQL

Categories

PostgresGUI

Numeric

Use integer for most things, numeric for money

smallint2 bytes

Enum-like values, small counters, ages. Saves space in wide tables.


Range

-32,768 to 32,767

Performance

Fastest integer type. Use when values always fit in 16 bits.

Comparison

smallint vs integer: saves 2 bytes per row. Only matters in tables with millions of rows and many small-int columns. Default to integer unless optimizing storage.

SQL Example
CREATE TABLE products (
  id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
  rating smallint CHECK (rating BETWEEN 1 AND 5)
);
PostgreSQL Numeric Types — integer, bigint, numeric, float | PostgresGUI