development:database:mysql:su-dung-explain-de-toi-uu-cau-lenh-mysql
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
development:database:mysql:su-dung-explain-de-toi-uu-cau-lenh-mysql [2024/11/11 14:36] – tungnt | development:database:mysql:su-dung-explain-de-toi-uu-cau-lenh-mysql [2024/11/11 14:41] (current) – [Khác] tungnt | ||
---|---|---|---|
Line 440: | Line 440: | ||
* Query bị thiếu index => lúc query nó phải scan rất nhiều data => RAM thiếu dẫn đến IO wait nó cũng tăng theo (độ trễ khi đọc data từ ổ cứng) | * Query bị thiếu index => lúc query nó phải scan rất nhiều data => RAM thiếu dẫn đến IO wait nó cũng tăng theo (độ trễ khi đọc data từ ổ cứng) | ||
+ | * Sử dụng 1 cột trong DB để đánh partition và cột đó tham gia query luôn. Ví dụ cột approved_time luôn có giá trị thì có thể sử dụng cột đó để đánh partition. Khi approved_time thay đổi thì cơ chế của DB sẽ tự chuyển đổi vị trí lưu theo partition. | ||
+ | * Loại bỏ index không cần thiết (dung lượng index không nên nhiều hơn dung lượng của data) => SELECT * FROM information_schema.partitions WHERE TABLE_SCHEMA=' | ||
+ | |||
+ |
development/database/mysql/su-dung-explain-de-toi-uu-cau-lenh-mysql.1731335815.txt.gz · Last modified: 2024/11/11 14:36 by tungnt