Trung BìnhPostgreSQL iconPostgreSQL

Migration schema PostgreSQL cần làm sao để ít downtime?

Migration ít downtime nên tránh rewrite/lock lớn trong giờ cao điểm. Pattern an toàn: add nullable column, backfill theo batch, deploy app đọc/ghi tương thích, sau đó add constraint/index concurrently khi có thể.

Ví dụ index production:

sql
CREATE INDEX CONCURRENTLY idx_orders_created_at ON orders (created_at);

Không chạy migration nguy hiểm chung với deploy app nếu không biết lock level.

Luôn test trên dữ liệu gần production và có rollback plan.

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

Mở danh sách PostgreSQL