How to Find Slow SQL: Databases for Developers: Performance #9
In order to tune SQL, you need to know what the slow statement is. But often you're just told that "the database" is slow!
To find the slow components, you need a breakdown of how long each piece of code takes to execute. You can do this in Oracle Database using:
- A SQL trace
- The PL/SQL hierarchical profiler
This video shows you how to do these with Oracle SQL Developer.
The script to spool the trace file is:
-----
set serveroutput off
set pagesize 0
set echo off
set feedback off
set trimspool on
set heading off
set tab off
set long 1000000
spool c:\temp\student_trace.trc
select payload
from v$diag_trace_file_contents
where trace_filename = (
select substr (
value,
instr ( value, '/', -1 ) + 1
) filename
from v$diag_info
where name = 'Default Trace File'
)
order by line_number;
spool off
-----
Need help with SQL?
Ask us over on AskTOM: https://asktom.oracle.com
Twitter: https://twitter.com/ChrisRSaxon
Daily SQL Twitter tips: https://twitter.com/SQLDaily
All Things SQL blog: https://blogs.oracle.com/sql/
Test your SQL Skills on the Oracle Dev Gym: https://devgym.oracle.com/
============================
The Magic of SQL with Chris Saxon
Copyright © 2020 Oracle and/or its affiliates. Oracle is a registered trademark of Oracle and/or its affiliates. All rights reserved. Other names may be registered trademarks of their respective owners. Oracle disclaims any warranties or representations as to the accuracy or completeness of this recording, demonstration, and/or written materials (the “Materials”). The Materials are provided “as is” without any warranty of any kind, either express or implied, including without limitation warranties or merchantability, fitness for a particular purpose, and non-infringement.
Видео How to Find Slow SQL: Databases for Developers: Performance #9 канала The Magic of SQL
To find the slow components, you need a breakdown of how long each piece of code takes to execute. You can do this in Oracle Database using:
- A SQL trace
- The PL/SQL hierarchical profiler
This video shows you how to do these with Oracle SQL Developer.
The script to spool the trace file is:
-----
set serveroutput off
set pagesize 0
set echo off
set feedback off
set trimspool on
set heading off
set tab off
set long 1000000
spool c:\temp\student_trace.trc
select payload
from v$diag_trace_file_contents
where trace_filename = (
select substr (
value,
instr ( value, '/', -1 ) + 1
) filename
from v$diag_info
where name = 'Default Trace File'
)
order by line_number;
spool off
-----
Need help with SQL?
Ask us over on AskTOM: https://asktom.oracle.com
Twitter: https://twitter.com/ChrisRSaxon
Daily SQL Twitter tips: https://twitter.com/SQLDaily
All Things SQL blog: https://blogs.oracle.com/sql/
Test your SQL Skills on the Oracle Dev Gym: https://devgym.oracle.com/
============================
The Magic of SQL with Chris Saxon
Copyright © 2020 Oracle and/or its affiliates. Oracle is a registered trademark of Oracle and/or its affiliates. All rights reserved. Other names may be registered trademarks of their respective owners. Oracle disclaims any warranties or representations as to the accuracy or completeness of this recording, demonstration, and/or written materials (the “Materials”). The Materials are provided “as is” without any warranty of any kind, either express or implied, including without limitation warranties or merchantability, fitness for a particular purpose, and non-infringement.
Видео How to Find Slow SQL: Databases for Developers: Performance #9 канала The Magic of SQL
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
What to Look for in Execution Plans: Databases for Developers: Performance #3How to Make Inserts, Updates, and Deletes Faster: Databases for Developers: Performance #8How do nested loop, hash, and merge joins work? Databases for Developers Performance #79 SQL Server Performance Tuning Tips - SQL in Sixty Seconds 168Count Millions of Rows Fast with Materialized Views: Databases for Developers: Performance #6Why Is My Query Slow? More Reasons Storing Dates as Numbers Is BadDatabase Tutorial for BeginnersHow to Read an Execution Plan: Databases for Developers: Performance #1What are Optimizer Statistics? Databases for Developers: Performance #2SQL Server Performance issues || SQL Server Long Running Query || SQL Server Query Running SlowHow to write SQL queries: Databases for Developers #4Finding Slow PL/SQL: Use the Profilers!Joining Many Tables (Introduction to Oracle SQL)Why is my Oracle Database Slow? The SQL Developer Performance DashboardPostgreSQL : Find the slow running queries in postgresqlWhy Isn't My Query Using an Index? Databases for Developers: Performance #5Interview question 02 - slow running sql query ||sql interview questionsLearn 130 SQL Statements in 20 Minutes