--- tags: Series PostgreSQL --- # 000: Performance optimization với PostgreSQL Các câu truy vấn SQL chạy rất nhanh với Database local, nhưng lên môi trường production thì chậm hơn rùa bò. Vì sao vậy? Có một vài yếu tố liên quan đến môi trường như CPU chậm, RAM ít, bandwidth giới hạn, vô vàn các lý do từ bên thứ 3 mà anh em dev có thể nghĩ đến. Tuy nhiên có một thứ giả vờ quên là design lởm, query tồi :joy:. Và chính mình đã gặp trường hợp như vậy. Chạy local 0,1(s) nhưng lên production là 5(s)... Series lần này sẽ giới thiệu về cách phân tích, optimize và một vài tính chất của PostgreSQL để tăng performance. - [001: Có những cách nào để tối ưu SQL Query?](https://hackmd.io/@datbv/SysFaQctu) (published) - [002: Hiểu về Index để tăng performance với PosgreSQL P1](https://hackmd.io/@datbv/ryNap75Yd) (published) - [003: Hiểu về Index để tăng performance với PosgreSQL P2](https://hackmd.io/@datbv/Bkg-VZ0KO) (published) - [004: Hiểu về Index để tăng performance với PosgreSQL P3](https://hackmd.io/@datbv/HkBYqh1cu) (published) - [005: Hiểu về Join để tăng performance với PostgreSQL](https://hackmd.io/@datbv/SklsXkMqu) (published) - [006: Partitioning với PostgreSQL P1](https://hackmd.io/@datbv/rJWe3TEnO) (published) - [007: Partitioning với PostgreSQL P2](https://hackmd.io/@datbv/rJmgQpuhu) (published) - [008: Materialized view với PostgreSQL](https://hackmd.io/@datbv/BJvy-Yan_) (published) - [009: Optimistic lock và Pessimistic lock](https://hackmd.io/@datbv/ryceolmCu) (published) - [010: Exclusive lock và Shared lock](https://hackmd.io/@datbv/rkZU-FThu) (published) - [011: PostgreSQL multi-version concurrency control](https://hackmd.io/@datbv/B13LtmHC_) (published) - [012: PostgreSQL Vacuum là gì?](https://hackmd.io/@datbv/SJx4rBOCd) (published) - [013: Thực hành Vacuum với PostgreSQL](https://hackmd.io/@datbv/S1qOgSA0_) (published) - [014: PostgreSQL transaction isolation](https://hackmd.io/@datbv/HkBQuQBRO) - [015: PostgreSQL best practice](https://hackmd.io/@datbv/HyX4EUdRO) ### Reference - https://github.com/postgres/postgres - https://www.postgresql.org/docs/13/mvcc.html - https://stackify.com/postgresql-performance-tutorial/ - https://wiki.postgresql.org/wiki/Performance_Optimization - https://en.wikipedia.org/wiki/Multiversion_concurrency_control - https://www.geeksforgeeks.org/difference-between-shared-lock-and-exclusive-lock/ © [Dat Bui](https://www.linkedin.com/in/datbv/)