Thứ Hai, 7 tháng 3, 2022
DB 10: Execution Plans
By
thelam92
23:21
Trước khi DB thực thi 1 câu lệnh sql, thì optimizer phải tạo 1 Execution Plans cho câu lệnh sql đó.
Sau khi có Execution Plans thì DB sẽ thực thi Execution Plans này step by step.
-> vì vậy, để tìm nguyên nhân câu query bị chậm thì Execution Plans là nơi cần xem đầu tiên.
Oracle DB:
- EXPLAIN PLAN FOR select * from dual
- "EXPLAIN PLAN FOR" ko show execution plan mà save vào bảng PLAN_TABLE
- select * from table(dbms_xplan.display) - câu lệnh này sẽ show execution plan cho câu query vừa thực thi ở trên
- Phân tích các operations:
1. Index and Table Access
1.1. INDEX UNIQUE SCAN
sẽ chỉ thực thi duyệt B-tree. DB sẽ thực thi operation này nếu một ràng buộc duy nhất đảm bảo rằng các tiêu chí tìm kiếm sẽ không khớp với nhiều hơn một entry.
1.2. INDEX RANGE SCAN
DB sẽ thực thi duyệt B-tree và follows the leaf node chain to find all matching entries
1.3. INDEX FULL SCAN
Reads the entire index—all rows—in index order
1.4. INDEX FAST FULL SCAN
Reads the entire index—all rows—as stored on the disk, This operation is typically performed instead of a full table scan if all required columns are available in the index. Similar to TABLE ACCESS FULL, the INDEX FAST FULL SCAN can benefit from multi-block read operations
1.5. TABLE ACCESS BY INDEX ROWID
Retrieves a row from the table using the ROWID retrieved from the preceding index lookup
1.6. TABLE ACCESS FULL
Reads the entire table—all rows and columns—as stored on the disk
2. Join
2.1. NESTED LOOPS JOIN
2.2. HASH JOIN
2.3. MERGE JOIN
3. Sorting and Grouping
3.1. SORT ORDER BY
3.2. SORT ORDER BY STOPKEY
3.3. SORT GROUP BY
3.4. SORT GROUP BY NOSORT
3.5. HASH GROUP BY
4. Top-N Queries
4.1. COUNT STOPKEY
4.2. WINDOW NOSORT STOPKEY
Đăng ký:
Đăng Nhận xét (Atom)
0 nhận xét:
Đăng nhận xét