Nâng CaoPostgreSQL iconPostgreSQL

Partitioning trong PostgreSQL dùng khi nào?

Partitioning chia bảng lớn thành partitions theo range/list/hash, thường dùng cho time-series/events/orders lớn. Lợi ích: partition pruning, quản lý retention dễ hơn, maintenance từng partition nhẹ hơn.

Ví dụ range partition theo tháng:

sql
CREATE TABLE events (
  id bigint,
  created_at timestamptz NOT NULL
) PARTITION BY RANGE (created_at);

Partitioning không tự động làm query nhanh nếu query không filter theo partition key hoặc index sai.

Nó cũng tăng complexity migration và operations.

Xem toàn bộ PostgreSQL cùng filter theo level & chủ đề con.

Mở danh sách PostgreSQL