TungNT (Blue)

tungnt.blue@gmail.com

User Tools

Site Tools


development:database:mysql:su-dung-explain-de-toi-uu-cau-lenh-mysql

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
development:database:mysql:su-dung-explain-de-toi-uu-cau-lenh-mysql [2024/11/11 14:36] tungntdevelopment: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='stg_api_console' AND TABLE_NAME = 'user_transactions' AND PARTITION_NAME IS NOT NULL; => Chỉ số cột: DATA_LENGTH, INDEX_LENGTH
 +
 +
development/database/mysql/su-dung-explain-de-toi-uu-cau-lenh-mysql.1731335815.txt.gz · Last modified: 2024/11/11 14:36 by tungnt

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki