<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Database on Dat Luong blog</title><link>https://datluongductuan.github.io/tags/database/</link><description>Recent content in Database on Dat Luong blog</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Sat, 04 Apr 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://datluongductuan.github.io/tags/database/index.xml" rel="self" type="application/rss+xml"/><item><title>Tại sao PostgreSQL chọn PANIC khi fsync thất bại? Tìm hiểu về tính bền vững trong database</title><link>https://datluongductuan.github.io/post/tai-sao-postgresql-chon-panic-khi-fsync-that-bai/</link><pubDate>Sat, 04 Apr 2026 00:00:00 +0000</pubDate><guid>https://datluongductuan.github.io/post/tai-sao-postgresql-chon-panic-khi-fsync-that-bai/</guid><description>~17 phút đọc
Vào 1 ngày đóng vai sinh viên hệ &amp;ldquo;online&amp;rdquo; của trường Carnegie Mellon University, nghe thầy Andy Pavlo giảng về database, đọc đến đoạn Postgresql sẽ panic khi gọi system call fsync() bị lỗi. Tôi thực sự bất ngờ, lý do đơn giản thôi, một tượng đài database như vậy phải xử lý mượt mà không vết xước chứ nhỉ, vậy tính Durable trong 4 nguyên tắc ACID của hệ quản trị cơ sở dữ liệu như nào?</description></item><item><title>[Case study] Tôi đã tối ưu 1 query PostgreSQL từ ~60s xuống còn ~2s như thế nào</title><link>https://datluongductuan.github.io/post/toi-uu-query-postgresql-60s-xuong-2s/</link><pubDate>Sat, 11 Jan 2025 00:00:00 +0000</pubDate><guid>https://datluongductuan.github.io/post/toi-uu-query-postgresql-60s-xuong-2s/</guid><description>TLDR;
Đánh index với WHERE mà WHERE chỉ filter được 50% rows thì planner PostgreSQL chọn seq scan (full table scan) vì hiệu quả hơn. PostgreSQL để cấu hình mặc định shared_buffer 128MB, mà tài nguyên RAM máy chủ đang có nhiều hơn → cần tăng lên để tận dụng hết tài nguyên. Dữ liệu query theo nghiệp vụ quá nhiều, từ 500MB đến 1GB cho 1 bảng xong câu lệnh SQL lại UNION ALL ghép lại → cần áp dụng một số cơ chế sử dụng bộ nhớ đệm như mview, cache superset hoặc thêm filter timestamp.</description></item></channel></rss>