Pick the right PostgreSQL type quickly
PostgreSQL has a rich set of built-in data types across numeric, character, date/time, JSON, network, geometric and array categories. This reference lets you search those types by name, alias or range and filter by category, so you can choose the smallest correct type for each column. It runs entirely in your browser.
How it works
Each entry lists the canonical type name, common aliases (e.g. int4 for
integer), the category, the storage size and the value range or notes.
Fixed-width types like integer and bigint always occupy the same number of
bytes, while variable-length types such as text, numeric and jsonb store
only the bytes they need plus a small length header. Choose types like this:
CREATE TABLE invoice (
id bigserial PRIMARY KEY,
total numeric(12,2) NOT NULL,
paid_at timestamptz,
metadata jsonb
);
Tips and examples
- Use
bigint/bigserialfor identifiers that may exceed two billion rows over the lifetime of a table — switching later is painful. - Index
jsonbcolumns with a GIN index to make containment queries (@>) fast. numericwithout a precision allows arbitrary precision; add(precision, scale)likenumeric(12,2)to constrain it.- For network data prefer
inet/cidrover text: they validate input and let you query by subnet.