← Ghi chú← Notes

PostgreSQL DBAPostgreSQL DBA

20 ghi chú20 notes

  1. 01Giới thiệu & Khái niệm RDBMSIntroduction & RDBMS ConceptsMột RDBMS (Relational Database Management System — hệ quản trị cơ sở dữ liệu quan hệ) lưu trữ dữ liệu dưới dạng tập hợp các bảng (table) — lưới gồm các hàng (row) và cột (column) — và cho phép bạn liên kết bảng này với…A relational database management system (RDBMS) stores data as a collection of tables — grids of rows and columns — and lets you relate one table to another through shared key values instead of through pointers or…19 Th7, 2026Jul 19, 2026
  2. 02Cài đặt, Thiết lập & Kết nốiInstallation, Setup & ConnectingTrước khi có thể quản trị một database PostgreSQL, bạn cần một instance đang chạy mà bạn có thể kết nối tới. Nghe có vẻ đơn giản, nhưng cách "đúng" để cài đặt và khởi động PostgreSQL khác nhau khá nhiều tùy vào việc bạn…Before you can administer a PostgreSQL database, you need a running instance you can reach. That sounds trivial, but the "right" way to install and start PostgreSQL differs quite a bit depending on whether you're…19 Th7, 2026Jul 19, 2026
  3. 03Kiểu dữ liệu & Đối tượng SchemaData Types & Schema ObjectsMỗi cluster PostgreSQL là một khu rừng các container lồng vào nhau: một database chứa nhiều schema, một schema chứa các relation (table, view, sequence, v.v.), và một relation chứa các column, mỗi column đều có kiểu dữ…Every PostgreSQL cluster is a forest of containers nested inside one another: a database holds schemas, a schema holds relations (tables, views, sequences, and more), and a relation holds columns, each of which is…19 Th7, 2026Jul 19, 2026
  4. 04Truy vấn dữ liệu: SQL cơ bảnQuerying Data: SQL FundamentalsTrước khi một database administrator có thể tune một query, thiết kế index, hay lý giải một execution plan chậm, họ phải viết được query đó trước đã. Bài này là phần thực hành song song với lý thuyết relational đã trình…Before a database administrator can tune a query, design an index, or reason about a slow execution plan, they have to be able to write the query in the first place. This topic is the hands-on counterpart to the…19 Th7, 2026Jul 19, 2026
  5. 05Truy vấn nâng caoAdvanced QueryingCác câu lệnh SELECT ... WHERE ... JOIN cơ bản đã giải quyết được nhiều bài toán, nhưng báo cáo, phân tích dữ liệu, và các bài toán dữ liệu phân cấp trong thực tế đòi hỏi một bộ công cụ phong phú hơn. Bài viết này trình…Basic SELECT ... WHERE ... JOIN statements take you a long way, but real-world reporting, analytics, and hierarchical data problems demand a richer toolbox. This note covers the constructs that separate someone who can…19 Th7, 2026Jul 19, 2026
  6. 06Sửa đổi & Nạp dữ liệu hàng loạtModifying & Bulk-Loading DataViệc đọc dữ liệu (query) thường chiếm phần lớn sự chú ý trong các tài liệu SQL, nhưng một DBA dành thời gian không kém để nghĩ về cách dữ liệu được ghi. Mỗi câu lệnh INSERT, UPDATE, DELETE đều phải đi qua toàn bộ cơ chế…Reading data gets most of the attention in SQL tutorials, but a DBA spends just as much time thinking about how data gets written. Every INSERT, UPDATE, and DELETE has to go through PostgreSQL's transactional machinery…19 Th7, 2026Jul 19, 2026
  7. 07Procedure, Function & TriggerProcedures, Functions & TriggersPostgreSQL cho phép đưa logic xử lý vào ngay trong database, thay vì (hoặc bên cạnh) tầng application. Có ba khối xây dựng chính giúp làm điều này: function, trả về một giá trị và có thể nhúng thẳng vào SELECT, WHERE…PostgreSQL lets you push logic into the database itself, instead of (or in addition to) the application layer. Three building blocks make this possible: functions, which compute and return a value and can be embedded…19 Th7, 2026Jul 19, 2026
  8. 08Chiến lược IndexingIndexing StrategiesIndex là một cấu trúc dữ liệu riêng, được sắp xếp theo thứ tự, giúp PostgreSQL tìm ra các row mà không cần quét toàn bộ table. Nếu không có index, mọi truy vấn vào table đều là sequential scan: PostgreSQL đọc từng…An index is a separate, ordered data structure that lets PostgreSQL find rows without scanning the entire table. Without one, every query against a table is a sequential scan: PostgreSQL reads every block, checks every…19 Th7, 2026Jul 19, 2026
  9. 09Transaction & Concurrency ControlTransactions & Concurrency ControlMọi database đều phải trả lời một câu hỏi khó chịu như nhau: điều gì xảy ra khi hai thao tác cùng đụng vào một dữ liệu tại cùng một thời điểm? Câu trả lời của PostgreSQL xoay quanh hai trụ cột — transaction, gom nhiều…Every database has to answer the same uncomfortable question: what happens when two things try to touch the same data at the same time? PostgreSQL's answer is built around two pillars — transactions, which group…19 Th7, 2026Jul 19, 2026
  10. 10Query Planning & Performance TuningQuery Planning & Performance TuningMỗi câu lệnh SQL bạn gửi cho PostgreSQL chỉ mô tả cái bạn muốn, chứ không nói làm thế nào để lấy được nó. Giữa văn bản SQL và các dòng dữ liệu trả về là query planner (còn gọi là optimizer): thành phần trong backend…Every SQL statement you send to PostgreSQL is a description of what you want, not how to get it. Between the SQL text and the rows that come back sits the query planner (also called the optimizer): a piece of the…19 Th7, 2026Jul 19, 2026
  11. 11Storage Internals & VacuumStorage Internals & VacuumTất cả các chủ đề trước trong series này coi "row" là một khái niệm logic — thứ bạn INSERT, SELECT, và suy luận bằng các quy tắc snapshot của MVCC (xem 09 — Transactions and Concurrency Control). Bài này đi xuống dưới…Every earlier topic in this series has treated a "row" as a logical concept — something you INSERT, SELECT, and reason about with MVCC snapshot rules (see 09 — Transactions and Concurrency Control). This note goes…19 Th7, 2026Jul 19, 2026
  12. 12Partitioning & ShardingPartitioning & ShardingMột bảng ban đầu nhỏ và hợp lý, sau vài năm và vài trăm triệu dòng, có thể trở thành thứ khiến mọi tác vụ vận hành trở nên đau đầu: sequential scan mất hàng phút thay vì mili-giây, CREATE INDEX khóa bảng trong một…A table that started small and reasonable can, a few years and a few hundred million rows later, become the thing that makes every operational task painful: sequential scans take minutes instead of milliseconds, CREATE…19 Th7, 2026Jul 19, 2026
  13. 13Replication & High AvailabilityReplication & High AvailabilityMột instance PostgreSQL đơn lẻ luôn là một single point of failure. Đĩa có thể hỏng, host có thể crash, một data center có thể mất điện — và bất kỳ sự kiện nào trong số đó cũng kéo cả database, cùng mọi ứng dụng phụ…A single PostgreSQL instance is a single point of failure. The disk can fail, the host can crash, a data center can lose power, and every one of those events takes the database — and every application that depends on it…19 Th7, 2026Jul 19, 2026
  14. 14Backup & RecoveryBackup & RecoveryBackup và recovery có lẽ là trách nhiệm quan trọng nhất mà một DBA PostgreSQL phải gánh vác. Sai sót về indexing chỉ làm chậm query; chiến lược vacuum tồi tốn dung lượng đĩa và gây bloat; nhưng một chiến lược backup tồi…Backup and recovery is arguably the single most consequential responsibility a PostgreSQL DBA carries. Indexing mistakes cost query latency; a botched vacuum strategy costs disk space and bloat; a bad backup strategy…19 Th7, 2026Jul 19, 2026
  15. 15Bảo mật & Access ControlSecurity & Access ControlBảo mật một PostgreSQL server thực chất là ba câu hỏi tách biệt chồng lên nhau. Thứ nhất: ai được phép mở connection, và từ đâu — đây là authentication, được kiểm soát bởi pghba.conf và lớp transport (TCP thường hay…Securing a PostgreSQL server is really three separate questions stacked on top of each other. First: who is allowed to even open a connection, and from where — that's authentication, controlled by pghba.conf and the…19 Th7, 2026Jul 19, 2026
  16. 16Monitoring, Logging & Chẩn đoánMonitoring, Logging & DiagnosticsMọi sự cố production đều bắt đầu bằng cùng một câu hỏi: "database đang thực sự làm gì ngay lúc này?" PostgreSQL trả lời câu hỏi đó ở ba lớp khác nhau, và một DBA giỏi cần thông thạo cả ba. Lớp trong cùng là statistics…Every production incident starts with the same question: "what is the database actually doing right now?" PostgreSQL answers that question at three different layers, and a competent DBA needs fluency in all three. The…19 Th7, 2026Jul 19, 2026
  17. 17Schema Design Pattern & Anti-patternSchema Design Patterns & Anti-PatternsLý thuyết normalization cho bạn biết làm sao để có một schema đúng: loại bỏ redundancy, tránh update anomaly, đảm bảo mỗi fact chỉ tồn tại đúng một nơi. Hầu hết DBA học các normal form một lần, vượt qua kỳ thi hay phỏng…Normalization theory tells you how to get a schema correct: eliminate redundancy, avoid update anomalies, make every fact live in exactly one place. Most DBAs learn the normal forms once, pass whatever exam or interview…19 Th7, 2026Jul 19, 2026
  18. 18Extension & Hệ sinh tháiExtensions & EcosystemHầu hết các hệ quản trị cơ sở dữ liệu quan hệ chỉ cho phép bạn thêm dữ liệu và code; rất ít hệ cho phép bạn thêm hẳn những loại dữ liệu mới, toán tử mới, và thuật toán index mới mà không cần fork server hay chờ chu kỳ…Most relational databases let you add data and code; very few let you add fundamentally new kinds of data, new operators, and new index algorithms without forking the server or waiting for a vendor release cycle…19 Th7, 2026Jul 19, 2026
  19. 19Automation & Infrastructure as CodeAutomation & Infrastructure as CodeCó một thời điểm rất cụ thể phân biệt một DBA đang quản lý một database với một DBA đang quản lý cả một hạm đội server: đó là khi một tác vụ cần được thực hiện giống hệt nhau, nhiều hơn một lần, dưới áp lực thời gian…There is a specific moment that separates a DBA who is managing one database from one who is managing a fleet: the moment a task needs to be done identically, more than once, under time pressure. SSHing into a server…19 Th7, 2026Jul 19, 2026
  20. 20Lập kế hoạch tài nguyên & Cộng đồngResource Planning & CommunityMọi chủ đề trong bộ kiến thức này cho đến giờ đều trả lời câu hỏi "làm thế nào": làm thế nào để model dữ liệu, làm thế nào để index, làm thế nào để replicate, làm thế nào để backup. Chủ đề cuối cùng này trả lời hai câu…Every topic in this knowledge base so far has answered a "how" question: how to model data, how to index it, how to replicate it, how to back it up. This final topic answers two different questions instead: "how much"…19 Th7, 2026Jul 19, 2026