Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Aaron Shilo
The document provides an overview of Oracle database performance tuning best practices for DBAs and developers. It discusses the connection between SQL tuning and instance tuning, and how tuning both the database and SQL statements is important. It also covers the connection between the database and operating system, how features like data integrity and zero downtime updates are important. The presentation agenda includes topics like identifying bottlenecks, benchmarking, optimization techniques, the cost-based optimizer, indexes, and more.
SQL Server Tuning to Improve Database PerformanceMark Ginnebaugh
SQL Server tuning is a process to eliminate performance bottlenecks and improve application service. This presentation from Confio Software discusses SQL diagramming, wait type data, column selectivity, and other solutions that will help make tuning projects a success, including:
•SQL Tuning Methodology
•Response Time Tuning Practices
•How to use SQL Diagramming techniques to tune SQL statements
•How to read executions plans
This is the presentation on ASH that I did with Graham Wood at RMOUG 2014 and that represents the final best effort to capture essential and advanced ASH content as started in a presentation Uri Shaft and I gave at a small conference in Denmark sometime in 2012 perhaps. The presentation is also available publicly through the RMOUG website, so I felt at liberty to post it myself here. If it disappears it would likely be because I have been asked to remove it by Oracle.
This ppt helps people who would like to present their industrial training presentation on Oracle 11g DBA.
This one includes all the operations that dba has to be perform and some other internal concepts of Oracle.
This document discusses techniques for optimizing SQL performance in Oracle databases. It covers topics like optimizing the optimizer itself through configuration changes and statistics collection, detecting poorly performing SQL, and methods for improving plans such as indexing, partitioning, hints and baselines. The goal is to maximize the optimizer's accuracy and ability to handle edge cases, while also knowing how to intervene when needed to capture fugitive SQL and ensure acceptable performance.
The document discusses Oracle Data Guard, a disaster recovery solution for Oracle databases. It provides:
1) An overview of Data Guard, explaining that it maintains a physical or logical standby copy of the primary database to enable failover in the event of outages or disasters.
2) Details on the different types of standby databases - physical, logical, and snapshot - and how they are maintained through redo application or SQL application.
3) The various Data Guard configuration options like real-time apply, time delay, and role transitions such as switchover and failover.
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Aaron Shilo
The document provides an overview of Oracle database performance tuning best practices for DBAs and developers. It discusses the connection between SQL tuning and instance tuning, and how tuning both the database and SQL statements is important. It also covers the connection between the database and operating system, how features like data integrity and zero downtime updates are important. The presentation agenda includes topics like identifying bottlenecks, benchmarking, optimization techniques, the cost-based optimizer, indexes, and more.
SQL Server Tuning to Improve Database PerformanceMark Ginnebaugh
SQL Server tuning is a process to eliminate performance bottlenecks and improve application service. This presentation from Confio Software discusses SQL diagramming, wait type data, column selectivity, and other solutions that will help make tuning projects a success, including:
•SQL Tuning Methodology
•Response Time Tuning Practices
•How to use SQL Diagramming techniques to tune SQL statements
•How to read executions plans
This is the presentation on ASH that I did with Graham Wood at RMOUG 2014 and that represents the final best effort to capture essential and advanced ASH content as started in a presentation Uri Shaft and I gave at a small conference in Denmark sometime in 2012 perhaps. The presentation is also available publicly through the RMOUG website, so I felt at liberty to post it myself here. If it disappears it would likely be because I have been asked to remove it by Oracle.
This ppt helps people who would like to present their industrial training presentation on Oracle 11g DBA.
This one includes all the operations that dba has to be perform and some other internal concepts of Oracle.
This document discusses techniques for optimizing SQL performance in Oracle databases. It covers topics like optimizing the optimizer itself through configuration changes and statistics collection, detecting poorly performing SQL, and methods for improving plans such as indexing, partitioning, hints and baselines. The goal is to maximize the optimizer's accuracy and ability to handle edge cases, while also knowing how to intervene when needed to capture fugitive SQL and ensure acceptable performance.
The document discusses Oracle Data Guard, a disaster recovery solution for Oracle databases. It provides:
1) An overview of Data Guard, explaining that it maintains a physical or logical standby copy of the primary database to enable failover in the event of outages or disasters.
2) Details on the different types of standby databases - physical, logical, and snapshot - and how they are maintained through redo application or SQL application.
3) The various Data Guard configuration options like real-time apply, time delay, and role transitions such as switchover and failover.
This document discusses Oracle database performance tuning. It covers identifying common Oracle performance issues such as CPU bottlenecks, memory issues, and inefficient SQL statements. It also outlines the Oracle performance tuning method and tools like the Automatic Database Diagnostic Monitor (ADDM) and performance page in Oracle Enterprise Manager. These tools help administrators monitor performance, identify bottlenecks, implement ADDM recommendations, and tune SQL statements reactively when issues arise.
Pythian is a global leader in database administration and consulting services. The document discusses the speaker's first 100 days of experience with an Oracle Exadata database machine. It provides an overview of Exadata components and features like Hybrid Columnar Compression and Smart Scan, which offloads processing from database servers to storage cells.
Oracle GoldenGate 18c - REST API ExamplesBobby Curtis
This document provides examples of using RESTful APIs with Oracle GoldenGate 18c. It includes examples of creating, deleting, and listing extracts, replicats, credentials, and distribution paths using cURL commands. It also provides examples of using RESTful APIs within shell scripts to automate administration tasks like adding extracts and replicats.
This document discusses Oracle database backup and recovery. It covers the need for backups, different types of backups including full, incremental, physical and logical. It describes user-managed backups and RMAN-managed backups. For recovery, it discusses restoring from backups and applying redo logs to recover the database to a point in time. Flashback recovery is also mentioned.
Monstercourses.com is the leading and pioneers in job oriented IT online training, offering best online training on all IT technologies by industry real time employees on hands on
Highlights:
Hands on trainers
Material
software installation
Resume guidance
One free demo
Affordable price
Quality online training
Placement assistance
MonsterCourses reviews teaching methodology is different and unique as the training programs designed helps the Learners to master in broad range of skills that is essential to become a creative IT professional. We have dedicated trainers who continuously work to improve quality of Online Training programs.
Learners who complete Graduation, Post Graduation and working employees were not adequately trained to meet today’s World of competition. So there was a great need for highly professional online training institute and in order to fill this gap MonsterCourses.com was started.
Our IT courses includes informatica online training, cognos online training, obiee online training, microstrategy online training ,datastage online training, teradata online training, BOXI online training, SAP FICO online training, abap online training, BOXI online training, oracle dba, sql/pl , dot net , QA online training and many more.
Join monstercourses.com for better career Opportunities
Pl contact <a href="http://www.monstercourses.com">www.monstercourses.com</a>
Phone: +17727771557
This document discusses upgrading to Oracle Database 19c and migrating to Oracle Multitenant. It provides an overview of key features such as being able to have 3 user-created PDBs without a Multitenant license in 19c. It also demonstrates how to use AutoUpgrade to perform an upgrade and migration to Multitenant with a single command. The document highlights various Multitenant concepts such as resource sharing, connecting to containers, and cloning PDBs.
This document discusses Oracle database backup and recovery using RMAN. It covers types of database failures that can occur and different backup options in Oracle, including physical and logical backups. It then describes the RMAN architecture and how RMAN allows for online backups while the database is running. The document compares manual versus RMAN backups and outlines some recommended RMAN backup strategies, including incremental strategies. It also provides examples of how RMAN can be used for database recovery in different failure scenarios.
The document discusses tuning SQL queries in Oracle databases. It begins by noting that while tools can help, there is no single process for tuning every query as each case depends on factors like the schema design, data distribution and how the optimizer chooses a plan. The document then provides a methodology for investigating and tuning a query with poor performance, including getting the execution plan, checking it visually, and identifying possible causes like stale statistics, missing indexes or inefficient SQL.
Database tuning is the process of optimizing a database to maximize performance. It involves activities like configuring disks, tuning SQL statements, and sizing memory properly. Database performance issues commonly stem from slow physical I/O, excessive CPU usage, or latch contention. Tuning opportunities exist at the level of database design, application code, memory settings, disk I/O, and eliminating contention. Performance monitoring tools like the Automatic Workload Repository and wait events help identify problem areas.
A preview into SQL Server 2019 from Bob, Asad and my presentation at PASS Summit 2018 (Nov '18). We provided insights into what our public preview builds for SQL Server 2019 had in November.
EM12c: Capacity Planning with OEM MetricsMaaz Anjum
Some of my thoughts and adventures encapsulated in a presentation regarding Capacity Planning, Resource Utilization, and Enterprise Managers Collected Metrics.
Database Consolidation using the Oracle Multitenant ArchitecturePini Dibask
The document discusses Oracle's Multitenant architecture, which allows multiple pluggable databases (PDBs) to consolidate within a single multitenant container database (CDB). It describes how Multitenant provides advantages like simplified upgrades, cloning, and migration of PDBs. The document also covers ensuring quality of service for PDBs using resource management, and how RAC supports high availability and scalability in a Multitenant environment. It concludes with a discussion of performance monitoring of workloads across PDBs.
Oracle Database is a relational database management system produced by Oracle Corporation. It stores data logically in tables, tablespaces, and schemas, and physically in datafiles. The database, SGA (containing the buffer cache, redo log buffer, and shared pool), and background processes like SMON, PMON, and DBWR work together for high performance and reliability. Backup methods and administrative tasks help maintain the database.
Oracle architecture with details-yogiji creationsYogiji Creations
Oracle is a database management system with a multi-tiered architecture. It consists of a database on disk that contains tables, indexes and other objects. An Oracle instance contains a memory area called the System Global Area that services requests from client applications. Background processes facilitate communication between the memory structures and database files on disk. Logical database structures like tablespaces, segments, extents and blocks help organize and manage the physical storage of data.
This document discusses AlwaysOn availability technologies in SQL Server 2017, including Failover Cluster Instances (FCI) and Availability Groups (AG). It provides an overview of how FCI and AG work to provide high availability and disaster recovery, including capabilities like multi-subnet support. The document also summarizes new features and enhancements to FCI and AG in SQL Server 2014, 2016 and 2017.
Oracle Transparent Data Encryption (TDE) 12cNabeel Yoosuf
This presentation provides an introduction to Oracle Transparent Data Encryption technology in 12c. It is provided as part of Oracle Advanced Security.
This document provides an overview of Oracle database history, architecture, components, and terminology. It discusses:
- Oracle's release history from 1978 to present.
- The physical and logical structures that make up an Oracle database, including data files, control files, redo logs, tablespaces, segments, and blocks.
- The Oracle instance and its memory components like the SGA and PGA. It describes the various background processes.
- How clients connect to Oracle using the listener, tnsnames.ora file, and naming resolution.
- Common Oracle tools for accessing and managing databases like SQLPlus, SQL Developer, and views for monitoring databases.
SQL Server High Availability Solutions (Pros & Cons)Hamid J. Fard
Proper SQL Server High Availability Solution Is Highly Depends on the Business Objective and IT Operation Objectives. It Happens Sometimes that We Might Have Few Solutions on the Table to Implement.
Pháp chứng kỹ thuật số cung cấp cho sinh viên với một cách tiếp cận có hệ thống khi tiến hành một điều tra pháp chứng máy tính (cả hai loại điều tra công quyền và điều tra công ty), các yêu cầu của một phòng thí nghiệm pháp chứng máy tính bao gồm cả thiết bị phục hồi dữ liệu, phần cứng và phần mềm cần thiết để xác nhận pháp chứng kỹ thuật số trong phòng thí nghiệm.
This document discusses Oracle database performance tuning. It covers identifying common Oracle performance issues such as CPU bottlenecks, memory issues, and inefficient SQL statements. It also outlines the Oracle performance tuning method and tools like the Automatic Database Diagnostic Monitor (ADDM) and performance page in Oracle Enterprise Manager. These tools help administrators monitor performance, identify bottlenecks, implement ADDM recommendations, and tune SQL statements reactively when issues arise.
Pythian is a global leader in database administration and consulting services. The document discusses the speaker's first 100 days of experience with an Oracle Exadata database machine. It provides an overview of Exadata components and features like Hybrid Columnar Compression and Smart Scan, which offloads processing from database servers to storage cells.
Oracle GoldenGate 18c - REST API ExamplesBobby Curtis
This document provides examples of using RESTful APIs with Oracle GoldenGate 18c. It includes examples of creating, deleting, and listing extracts, replicats, credentials, and distribution paths using cURL commands. It also provides examples of using RESTful APIs within shell scripts to automate administration tasks like adding extracts and replicats.
This document discusses Oracle database backup and recovery. It covers the need for backups, different types of backups including full, incremental, physical and logical. It describes user-managed backups and RMAN-managed backups. For recovery, it discusses restoring from backups and applying redo logs to recover the database to a point in time. Flashback recovery is also mentioned.
Monstercourses.com is the leading and pioneers in job oriented IT online training, offering best online training on all IT technologies by industry real time employees on hands on
Highlights:
Hands on trainers
Material
software installation
Resume guidance
One free demo
Affordable price
Quality online training
Placement assistance
MonsterCourses reviews teaching methodology is different and unique as the training programs designed helps the Learners to master in broad range of skills that is essential to become a creative IT professional. We have dedicated trainers who continuously work to improve quality of Online Training programs.
Learners who complete Graduation, Post Graduation and working employees were not adequately trained to meet today’s World of competition. So there was a great need for highly professional online training institute and in order to fill this gap MonsterCourses.com was started.
Our IT courses includes informatica online training, cognos online training, obiee online training, microstrategy online training ,datastage online training, teradata online training, BOXI online training, SAP FICO online training, abap online training, BOXI online training, oracle dba, sql/pl , dot net , QA online training and many more.
Join monstercourses.com for better career Opportunities
Pl contact <a href="http://www.monstercourses.com">www.monstercourses.com</a>
Phone: +17727771557
This document discusses upgrading to Oracle Database 19c and migrating to Oracle Multitenant. It provides an overview of key features such as being able to have 3 user-created PDBs without a Multitenant license in 19c. It also demonstrates how to use AutoUpgrade to perform an upgrade and migration to Multitenant with a single command. The document highlights various Multitenant concepts such as resource sharing, connecting to containers, and cloning PDBs.
This document discusses Oracle database backup and recovery using RMAN. It covers types of database failures that can occur and different backup options in Oracle, including physical and logical backups. It then describes the RMAN architecture and how RMAN allows for online backups while the database is running. The document compares manual versus RMAN backups and outlines some recommended RMAN backup strategies, including incremental strategies. It also provides examples of how RMAN can be used for database recovery in different failure scenarios.
The document discusses tuning SQL queries in Oracle databases. It begins by noting that while tools can help, there is no single process for tuning every query as each case depends on factors like the schema design, data distribution and how the optimizer chooses a plan. The document then provides a methodology for investigating and tuning a query with poor performance, including getting the execution plan, checking it visually, and identifying possible causes like stale statistics, missing indexes or inefficient SQL.
Database tuning is the process of optimizing a database to maximize performance. It involves activities like configuring disks, tuning SQL statements, and sizing memory properly. Database performance issues commonly stem from slow physical I/O, excessive CPU usage, or latch contention. Tuning opportunities exist at the level of database design, application code, memory settings, disk I/O, and eliminating contention. Performance monitoring tools like the Automatic Workload Repository and wait events help identify problem areas.
A preview into SQL Server 2019 from Bob, Asad and my presentation at PASS Summit 2018 (Nov '18). We provided insights into what our public preview builds for SQL Server 2019 had in November.
EM12c: Capacity Planning with OEM MetricsMaaz Anjum
Some of my thoughts and adventures encapsulated in a presentation regarding Capacity Planning, Resource Utilization, and Enterprise Managers Collected Metrics.
Database Consolidation using the Oracle Multitenant ArchitecturePini Dibask
The document discusses Oracle's Multitenant architecture, which allows multiple pluggable databases (PDBs) to consolidate within a single multitenant container database (CDB). It describes how Multitenant provides advantages like simplified upgrades, cloning, and migration of PDBs. The document also covers ensuring quality of service for PDBs using resource management, and how RAC supports high availability and scalability in a Multitenant environment. It concludes with a discussion of performance monitoring of workloads across PDBs.
Oracle Database is a relational database management system produced by Oracle Corporation. It stores data logically in tables, tablespaces, and schemas, and physically in datafiles. The database, SGA (containing the buffer cache, redo log buffer, and shared pool), and background processes like SMON, PMON, and DBWR work together for high performance and reliability. Backup methods and administrative tasks help maintain the database.
Oracle architecture with details-yogiji creationsYogiji Creations
Oracle is a database management system with a multi-tiered architecture. It consists of a database on disk that contains tables, indexes and other objects. An Oracle instance contains a memory area called the System Global Area that services requests from client applications. Background processes facilitate communication between the memory structures and database files on disk. Logical database structures like tablespaces, segments, extents and blocks help organize and manage the physical storage of data.
This document discusses AlwaysOn availability technologies in SQL Server 2017, including Failover Cluster Instances (FCI) and Availability Groups (AG). It provides an overview of how FCI and AG work to provide high availability and disaster recovery, including capabilities like multi-subnet support. The document also summarizes new features and enhancements to FCI and AG in SQL Server 2014, 2016 and 2017.
Oracle Transparent Data Encryption (TDE) 12cNabeel Yoosuf
This presentation provides an introduction to Oracle Transparent Data Encryption technology in 12c. It is provided as part of Oracle Advanced Security.
This document provides an overview of Oracle database history, architecture, components, and terminology. It discusses:
- Oracle's release history from 1978 to present.
- The physical and logical structures that make up an Oracle database, including data files, control files, redo logs, tablespaces, segments, and blocks.
- The Oracle instance and its memory components like the SGA and PGA. It describes the various background processes.
- How clients connect to Oracle using the listener, tnsnames.ora file, and naming resolution.
- Common Oracle tools for accessing and managing databases like SQLPlus, SQL Developer, and views for monitoring databases.
SQL Server High Availability Solutions (Pros & Cons)Hamid J. Fard
Proper SQL Server High Availability Solution Is Highly Depends on the Business Objective and IT Operation Objectives. It Happens Sometimes that We Might Have Few Solutions on the Table to Implement.
Pháp chứng kỹ thuật số cung cấp cho sinh viên với một cách tiếp cận có hệ thống khi tiến hành một điều tra pháp chứng máy tính (cả hai loại điều tra công quyền và điều tra công ty), các yêu cầu của một phòng thí nghiệm pháp chứng máy tính bao gồm cả thiết bị phục hồi dữ liệu, phần cứng và phần mềm cần thiết để xác nhận pháp chứng kỹ thuật số trong phòng thí nghiệm.
Bài thuyết trình môn học Hệ Điều Hành.pptxduongchausky
Hệ điều hành là một môn học cung cấp kiến thức cơ bản về quản lý tài nguyên của máy tính. Dưới đây là một số nội dung chính của môn học hệ điều hành:
Định nghĩa và tính chất của hệ điều hành:
Định nghĩa và tính chất cơ bản của hệ điều hành.
Lịch sử phát triển hệ điều hành.
Phân loại hệ điều hành.
Quản lý tiến trình:
Tiến trình và luồng (process/thread).
Đồng bộ hóa tiến trình.
Lập lịch CPU.
Tắc nghẽn và xử lý tắc nghẽn:
Khái niệm tắc nghẽn.
Điều kiện xảy ra tắc nghẽn.
Các phương pháp xử lý tắc nghẽn.
Quản lý bộ nhớ:
Khái niệm chung về quản lý bộ nhớ.
Các chiến lược quản lý bộ nhớ thực.
Quản lý bộ nhớ ảo.
Quản lý tập tin:
Hệ thống quản lý tập tin.
Thư mục và cách cài đặt hệ thống file và thư mục.
Quản lý nhập xuất:
Hệ thống vào ra.
Xử lý vào ra.
Quản lý truy cập đĩa.
Môn học hệ điều hành giúp bạn hiểu nguyên tắc hoạt động của hệ điều hành và cung cấp kiến thức cơ bản để xây dựng và quản lý các hệ điều hành cụ thể. Nếu bạn muốn tìm hiểu thêm, có thể xem các tài liệu chi tiết về môn học này.
4. Blocking
• SQL Server dùng các lock để duy trì sự toàn vẹn data cho việc đọc và ghi
• Chỉ một process có quyền kiểm soát data tại một thời điểm
• Có vài kiểu lock được dùng như Shared, Update, Exclusive, Intent …
• Blocking sinh ra khi có 2 process cùng muốn truy cập vào cùng một data
và process thứ 2 phải chờ đến khi process thứ 1 release lock
• Thông thường thì thời gian các lock được giữ là rất nhỏ
• Lock được giữ lâu hơn khi update data
• Lock cũng được dùng khi read data
5. Deadlocks
• Vấn đề phổ biến của SQL Server là deadlock
• Deadlock sinh ra khi 2 hoặc nhiều process cùng chờ một resource và
mỗi process chờ process khác hoàn thành
• Khi xảy ra deadlock và không có cách để xử lý các xung đột này, thì SQL
Server sẽ chọn một process xem là một deadlock victim và rollback
process đó, để các process khác có thể chạy tiếp
6. I/O bottlenecks
• SQL Server thường là một process hoạt động I/O cao
• SQL Server phải lấy data từ disk để đáp ứng cho các query
• Một process khác dùng nhiều I/O là database TempDB, Transaction Log
• TempDB là một khu vực làm việc tạm thời của SQL Server để làm những
việc như sort và group
• I/O là một phần quan trọng của SQL Server performance, cần chắc chắn
việc disk không bị bottleneck
• Vấn đề I/O không phải chỉ do disk, mà do cả vấn đề Index, Poor query,
Fragmentation hoặc Statistics quá hạn
7. Index
• Index là yếu tố quan trọng trong việc tối ưu query
• Các kiểu index
▫ Non-Clustered
▫ Clustered
▫ Covering
▫ Filtered
• Các việc làm dẫn đến giảm tối ưu query và database
▫ Không tạo Index
▫ Tạo quá nhiều Index trên một table
▫ Index sai column
▫ Không có kế hoạch bảo trì Index
8. Statistics
• Statistic là object chứa các thông tin thống kê về sự phân tán dữ liệu trong một hoặc nhiều column
của một table hoặc index view.
• Statistic chứa thông tin về index
• Query optimizer dùng statistic để tạo query plan giúp tăng performance của query
• Một vài trường hợp, cần tạo thêm statistic hoặc thay đổi query cho kết quả tốt nhất
• Statistic được create khi :
▫ Query optimizer tạo statistic cho các index của table hoặc view khi index được tạo
▫ Query optimizer tạo statistic cho các column đơn khi AUTO_CREATE_STATISTICS is on
• Statistic được update khi :
▫ Query optimizer xác định khi nào statistic có thể quá hạn và sau đó update chúng khi cần
▫ AUTO_UPDATE_STATISTICS is on
▫ Dùng câu lệnh UPDATE STATISTICS hoặc store procedure sp_updatestats
9. Fragmentation
• Sự phân mảnh là sự lưu trữ data không liên tục trên disk
• Internal Fragmentation
▫ Record lưu trữ không tiên tục trong page
▫ Xuất hiện các không gian không được dùng giữa các record trong page
▫ Sinh ra khi dùng các lệnh INSERT, UPDATE, DELETE
• External Fragmentation
▫ Các page được lưu trữ vật lý trong một phạm vi (Extent)
▫ Các Extent lưu trữ vật lý không liên tục trên disk
• Logical Fragmentation
▫ Các page index duy trì sự sắp xếp logic của page trong extent
▫ Do Page split mà các page bị mất trật tự
10. Wait stats
• Đưa ra thông tin về thời gian chờ việc thực thi của các thread đối với các tài
nguyên của hệ thống
• Có rất nhiều các thông số khác nhau về các loại tài nguyên của hệ thống
▫ PAGEIOLATCH_SH xảy ra khi một thead chờ đợi trên một chốt cho một bộ đệm đó
là trong một yêu cầu I/O. Yêu cầu chốt là ở chế độ Shared. Long waits có thể chỉ ra
vấn đề với disk
▫ OLEDB chờ một giao tiếp dùng OLEDB như linked server
▫ CXPACKET xảy ra với các truy vấn song song
▫ ASYNC_NETWORK_IO xảy ra khi SQL Server chờ một client lấy dữ liệu
• Dựa vào các thông số trên để điều tra nguyên nhân gây ra vấn đề về hiệu
năng của hệ thống
11. Poor query plan
• Tạo câu lệnh truy vấn dữ liệu không tối ưu
▫ Lấy ra những column không cần dùng
▫ Tính toán dữ liệu dựa trên các column trong câu lệnh JOIN và WHERE
▫ Dùng sub-query
▫ Dùng con trỏ
▫ …
▫ Index không có hoặc sai hoặc không được bảo trì
▫ Statistic không được update
▫ …
Developer
DBA
12. Tool SQLProfiler
• Bắt request vào database theo thời gian thực
• Filter các request theo khoảng thời gian thực thi của query
• Tổng hợp thông tin request trong một khoảng thời gian ra file CSV
• Thống kê Index: index đang dùng, index không dùng, cách index được
dùng query
• Thống kê Query: query dùng nhiều, query chạy chậm, query tốn tài
nguyên I/O, CPU…
• Thống kê Wait: thời gian chờ trong quá trình xử lý để đáp ứng các query
của instance SQL Server trên server (không áp dụng trên 1 database)
15. Số lần query dùng kiểu seek trên index
Seek là kiểu nhanh nhất để access data
Số lần query dùng kiểu scan trên index
Scan là khi nhiều row data phải được tìm kiếm
Số lần query từ một clusterd index hoặc heap
Số lần index được update do sự
thay đổi dữ liệu
16. Sự phân mảnh của index theo %
Reorganize index khi sự phân mảnh nằm trong
khoảng từ 5% - 30%
Rebuild index khi sự phân mảnh trên 30%
17. Đây là những index không dùng, có thể đưa
ra table của index đó cũng không được dùng
=> Xem xét xóa
18. Thời gian query plan được biên dịch
Thời gian gần nhất mà query chạy
Số lần chạy từ khi creation_time đến last_execuation_time
Nội dung câu lệnh query
19. Thống kê về thời gian chờ của các hoạt động của
cả hệ thống SQL Server, như I/O, Network,
OLEDB…
20. Thông tin index trong Execution plan
• Ctrl + M trong SSMS để bật tính năng execution plan và chạy query
Query dữ liệu trong table không có Index
Query dữ liệu trong table trên index Nonclustered
Query dữ liệu trong table trên index Clustered
Query dữ liệu trong table trên index Non-Clustered nhưng cần thêm dữ liệu từ một index Clusterd
Query dữ liệu trong table trên index Non-Clustered nhưng cần thêm dữ liệu và table ko có index Clusterd
Estimated Subtree Cost là giá trị tổng chi phí của query optimizer cho việc chạy query và tất cả
các hoạt động trước nó trên cùng subtree. Giá trị nhỏ nghĩa là nó cần ít resource
21. Tối ưu query dùng Database Engine Tuning Advisor
• Xem chi tiết tại đây.
22. Sự sai khác execution plan và thời gian thực thi trong
store procedure
• Nguyên nhân
▫ Constant value
▫ Parameter sniffing
• Cách khắc phục
▫ RECOMPILE
▫ OPTIMISE FOR UNKNOWN (từ phiên bản SQL Server 2008)
▫ Parameter masking
Overview
Khi các Lock được giữ trong khoảng thời gian thì chúng sinh ra blocking, có nghĩa 1 process phải chờ cho đến khi process khác hoàn thành và release lock
Giống với deadlocking khi mà 2 process cùng chờ dùng một resource
Không giống với deadlocking vì blocking được xử lý ngay khi process release resource
Explanation
Khi dữ liệu được update thì một Update lock được dùng và khi dữ liệu được đọc thì một Shared lock được dung
Update lock sẽ tạo một Exclusive lock trên dữ liệu mà process dùng
Shared lock cho phép các process khác dùng Shared lock để truy cập dữ liệu
Khi mà 2 process cùng truy cập vào cùng một dữ liệu thì đó là khi locking và blocking xảy ra
Xem thêmhttps://www.mssqltips.com/sqlservertutorial/253/troubleshooting-blocking/
Mặc định khi deadlock xảy ra, ứng dụng của bạn có thể bắt và handle error, nhưng trong SQL Server Error Log hoặc Window Event Log sẽ không bắt lỗi này
Xem thêm
https://www.mssqltips.com/sqlservertutorial/252/tracing-a-sql-server-deadlock/
Overview
Hầu hết các trường hợp Database có dung lượng lớn hơn dung lượng của bộ nhớ máy tính được cài đặt và do đó SQL Server phải lấy data từ disk để đáp ứng cho các query
Do data trong database là luôn thay đổi, các thay đổi này cần ghi vào disk
TempDB cũng lưu trên disk do vậy sự phụ thuộc vào bao nhiêu object tạm được tạo trong database này có thể là hơn cả user database
I/O là một phần quan trọng của SQL Server performance, cần chắc chắn việc disk không bị bottleneck, trước đây thì việc này dễ để làm do các server có cắm disk để lưu trữ tại đó.
Xem thêm
https://www.mssqltips.com/sqlservertip/2329/how-to-identify-io-bottlenecks-in-ms-sql-server/
https://blogs.msdn.microsoft.com/sqljourney/2013/06/03/how-to-troubleshooting-sql-server-io-bottlenecks/
Overview
Vấn đề phổ biến trong Index là việc thiếu index hoặc index không đúng column do đó SQL Server phải xử lý nhiều data hơn để tìm ra bản ghi phù hợp với điều kiện của câu query
Vấn đề này sinh ra 2 kiểu tìm kiếm mà trong Execution plan gọi là Index Scans và Table Scans
Việc có quá nhiều index dẫn đến SQL Server phải bảo trì tất cả các index đó, điều này có thể gây chậm database …, và các index này cũng đòi hỏi không gian lưu trữ trên disk
Explanation
Index scan hoặc Table scan là khi SQL Server phải scan data hoặc các trang index để tìm ra bản ghi phù hợp
Ngược nghĩa với scan là seek, seek dùng index để xác định các bản ghi phù hợp với query
Scan yêu cầu nhiều I/O và cũng xử lý lâu hơn
Key Lookup cũng là một kiểu tìm kiếm cần tránh, xảy ra khi data được tìm trong một non-clustered index mà các dữ liệu thêm (ngoài các cột được index trong non-clustered index) trong query cần phải lấy từ clustered index. Nếu table không có clusterd index thì một RID Lookup thay thế
Kiểm tra trắc nghiệm trong 3 phút về SQL Index: http://use-the-index-luke.com/3-minute-test
Xem thêm
https://www.mssqltips.com/sqlservertutorial/277/index-scans-and-table-scans/
https://www.mssqltips.com/sqlservertutorial/258/eliminating-bookmark-keyrid-lookups/
https://www.codeproject.com/Articles/234399/Database-performance-optimization-part-Indexing
https://www.codeproject.com/Articles/243320/Database-performance-optimization-part-Index-mai
https://www.red-gate.com/simple-talk/sql/performance/identifying-and-solving-index-scan-problems/
Internal fragmentation
Những thay đổi này không phân bố đều giữa các row của table và các index, sự đầy đủ của mỗi page có thể thay đổi theo thời gian
Những không gian không dùng đến này gây ra việc sử dụng bộ nhơ kém và tốn nhiều I/O dẫn đến hiệu năng truy vấn kém
External fragmentation
Sự chuyển từ một Extent tới Extent khác gây ra sự xoay vòng disk cao hơn
Logical Fragmentation
Vì Page Split, các page bị mất sự sắp xếp.
Một page bị mất sự sắp xếp là page mà page vật lý tiếp theo được chỉ định tới một index là không phải là page được trỏ tới bởi con trỏ trang tiếp theo trong lá page hiện tại
Xem thêm
https://blog.sqlauthority.com/2010/01/12/sql-server-fragmentation-detect-fragmentation-and-eliminate-fragmentation/
Là một phương pháp để điều tra sự cố về hiệu năng của hệ thống SQL Server được gọi là “waits and queues” cũng được biết đến là “wait stats”
SQL Server luôn theo dõi việc thực thi
Sub-query là các query bên trong một query
Kiểu query này sẽ chạy đối với từng row của query bên ngoài trả ra, do đó làm giảm hiệu năng của truy vấn SQL
Ex:
SELECT c.Name,
c.City,
(SELECT CompanyName FROM Company WHERE ID = c.CompanyID) AS CompanyName
FROM Customer c
Dùng JOIN để thay thế
Ex:
SELECT c.Name,
c.City,
co.CompanyName
FROM Customer c LEFT JOIN Company co ON c.CompanyID = co.CompanyID
SQL Server’s scheduling system works
Thread dùng CPU (RUNNING) cho đến khi nó cần phải chờ một resource.
Sau đó di chuyển tới một unordered list chứa các thread gọi là SUSPENDED.
Trong khi đó, thread tiếp theo trong FIFO queue của các thread đang chờ CPU (RUNNABLE) được CPU chạy và chuyển thành RUNNING.
Nếu thread trong SUSPENDED list được thông báo là resource của nó đã có thể dùng, thì nó chuyển thành RUNNABLE và được chuyển xuống cuối queue.
Các thread tiếp tục chạy từ RUNNING đến SUSPENDED đến RUNNABLE đến RUNNING và lặp lại cho đến khi task hoàn thành.