SlideShare a Scribd company logo
SQLd360
SQL	diagnostic	made	easy
a.k.a.
Tune	SQLs	21st century	style
Mauro	Pagano
Trivia!
• History	quiz	about	Oracle	RDBMS!
– Was	any	feature	introduced	since	1998(*)?
– Did	any	of	them	has	to	do	the	optimizer?
– How	much	has	the	optimizer	changed	since?
– How	much	more	complex	has	the	CBO	become?
• One	answer	to	all	questions	=>	YES!	A	LOT
2(*)	Oracle	8i	release	date
The	last	20	years	of	Optimizer
• Shift	to	cost-based	optimization
– Instead	of	heuristic-based
– Introduced	statistics	necessity
• Query	Transformations
– Made	optimizer	way	more	sophisticated	(complex)
• Stability	vs	flexibility	challenge
– Conservative	way,	ensure	plans	NOT	change
– Progressive	way,	plans	DO	change
3
My	SQL	runs	slow…
• How	to	approach	a	SQL	tuning	challenge?
• “Classic”	3	steps	approach:
– Enable	tracing	events	(10053	&	10046)	
– Execute	the	SQL	again
– Review	trace	files
This	is	1998	SQL	Tuning!!!!
4
Seriously?	That’s	your	approach?	
• By	“classic”	I	meant	old!	J
• 10053&10046	has	many	limitations
– Need	to	be	put	in	place	BEFORE	exec	starts
• No	after-the-fact	investigation
– Hard	to	review	and	digest
• Have	you	ever	read	a	2M	lines	long	10053?
– Provide	limited	info	about	surrounding	env
• You	need	to	reconnect	&	gather	missing	pieces!	
1/29/17 5
What	can	be	improved?
• A	lot	more	info	needed	but:
– Not	trivial	to	collect	
– Time	sensitive	
– Some	are	pieces	you	just	don’t	know	about
• Need	a	new	way	to	
– Collect	everything	in	one	shot
– Be	able	to	execute	it	anytime
1/29/17 6
Flash	forward	to	2007
• Meet	SQLTXPLAIN	a.k.a.	SQLT
– Free	tool	from	Oracle
– Authored	by	the	one	and	only	Carlos	Sierra
– Designed	by	Support,	for	Support
• Can	be	executed	at	any	time
• Collects	everything around	a	SQL	statement
1/29/17 7
So	SQLT	is	the	perfect	tool?
• SQLT	still	has	some	limitations
– Requires	installation,	two	schemas
– Presents	a	lot	of	RAW	info,	hard	to	digest	
– Main	focus	is	plan	generation,	not	much	on	exec
– Heavily	depends	on	rowsource info
This	is	2007	SQL	Tuning!!!!
1/29/17 8
What’s	wrong	with	2007?
• Oracle	RDBMS	11g	was	released
• Some	decisions	deferred	to	exec	time
– Plan	started	to	diverge	from	the	one	“on	paper”
• New	features	changed	SQL	Tuning	forever
– SQL	Monitoring	(got	better	in	11.2)
– ASH	data	collected	by	Execution	Plan	Line
1/29/17 9
Can	we	do	better	than	SQLT?
• Not	on	plan	generation,	SQLT	still	rocks
– But	most	of	the	time	that’s	Support	role,	not	ours
• Yes	on	data	presentation,	use	charts	to
– Consume	large	amount	of	info	quickly
– Hide	the	complexity	of	some	information
– Allow	for	trend	and	pattern	recognition
1/29/17 10
Really?	Better	than	
SQLT?
1/29/17 11
What	else	can	we	do?
• Leverage	new	features	from	Oracle
• SQL	Monitor	removes	dependency	on	10046
– Allow	to	better	focus	on	SQL	execution
– Also	historical	from	12c	onwards
• ASH	by	Plan	Line	allows	to:	
– Group	info	by	plan	line,	not	possible	with	10046
– Identify	bottlenecks	with	no	SQL	Mon	nor	10046
1/29/17 12
Meet	the	2016	
runaway-approved
SQL	Tuning	tool
1/29/17 13
Meet	SQLd360
• FREE!
• No	installation
• Can	be	executed	any	time
• Single	step	execution
• Extensive	use	of	visualization
• Leverage	existing	Oracle	features
1/29/17 14
SQLd360	use	Google	Charts
• Present	large	amount	of	info	as	charts
– Easy	to	consume	and	spot	trends	/	patterns
• FREE,	no	license	required
• Libraries	are	downloaded	from	Google
– Similar	to	SQL	Monitor	or	PerfHub
• Data	is	kept	local,	not	sent	to	Google
15
How	to	run	it
• Download	SQLd360	(my	blog	or	github)
• Refer	to	readme.txt J
• Connect	to	SQL*Plus	as	any	DBA	or	user	with	
access	to	Data	Dictionary
• Parameters
– SQL	ID	
– Oracle	Tuning	or	Diagnostics	Pack?	[T	|	D	|	N]
16
What’s	the	output?
• Single	ZIP	file
– Self-consistent,	allows	offline	analysis
– Only	Metadata	extracted,	no	application	data	
• Thousands	of	files
– Each	small	and	easy	to	consume
– Index.html drives	navigation
– Reports	with	different	granularity
– Specific	“drill-down”	pages
1/29/17 17
18
00001_sqld360_dbnamehash_sqlid_index.html
19
Report
Data
Source
DESC of	
source	table
Query
Copy&Paste
1/29/17 20
Bind	peeking,	data	distrib on	histogram
• 1998	SQL	Tuning	(aka	traces)
– Trace	each	exec	and	collect	histgram info	manually	
• 2007	SQL	tuning	(aka	SQLT)
– Provides	every	info	necessary
– Straightforward	to	spot	distribution
• But	still	requires	to	read	a	table	of	up	to	2048	rows
1/29/17 21
1/29/17 22
One	chart	per	histogram	
created	automatically Cardinality,	selectivity	and	
endpoint	conversion	
available	with	mouse-over
Easier	this	way?	J
SQL	Y	breaks	SLA	since	Monday
• 1998	SQL	Tuning	(aka	traces)
– Sorry,	can’t	help	you
• 2007	SQL	tuning	(aka	SQLT)
– Plan	stability	issue,	second	plan	is	takes	909	secs
PLAN_HASH_VALUE EXECS AVG_BUFFER_GETS AVG_ELAPSED_TIME_SECS
3716292209 43 195354839 909.592
4161077702 3 15562769 71.769
1/29/17 23
“But	my	SLA	is	
1000secs!!!!”
and	PHV	3716…	was	
used	before	Monday
Old	approaches	make	it	hard
• 2007	SQL	tuning	(aka	SQLT)
– Ops,	here	is	the	data,	figure	it	out
1/29/17 24
1/29/17 25
Average	elapsed	time/exec	
over	time	per	PHV
Executions	started	to	take	
longer	and	longer	over	time,	
even	original	plan	degraded.	
Likely	not	a	plan	issue
Easier	this	way?	J
Plan	performance	
evaluation	needs	time	
dimension!
CBO	used	this	plan,	it	seemed	slow
-------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | E-Rows |E-Bytes|E-Temp | Cost (%CPU)| E-Time |
-------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | | 11754 (100)| |
|* 1 | FILTER | | | | | | |
|* 2 | HASH JOIN | | 85222 | 8738K| 2792K| 11754 (1)| 00:02:22 |
| 3 | TABLE ACCESS BY INDEX ROWID | MTL_SYSTEM_ITEMS_B | 81549 | 1831K| | 9762 (1)| 00:01:58 |
|* 4 | INDEX RANGE SCAN | MTL_SYSTEM_ITEMS_B_N10 | 81549 | | | 277 (1)| 00:00:04 |
|* 5 | COUNT STOPKEY | | | | | | |
| 6 | INDEX FULL SCAN | MTL_PARAMETERS_N1 | 1 | 4 | | 1 (0)| 00:00:01 |
|* 7 | TABLE ACCESS FULL | SPRN_INV_ITEM_IN_INT | 55245 | 4423K| | 1608 (2)| 00:00:20 |
| 8 | NESTED LOOPS | | 1 | 37 | | 643 (1)| 00:00:08 |
| 9 | NESTED LOOPS | | 1 | 37 | | 643 (1)| 00:00:08 |
| 10 | NESTED LOOPS | | 1 | 20 | | 642 (1)| 00:00:08 |
|* 11 | TABLE ACCESS FULL | QP_LIST_LINES | 1 | 9 | | 641 (1)| 00:00:08 |
|* 12 | TABLE ACCESS BY INDEX ROWID| QP_LIST_HEADERS_B | 1 | 11 | | 1 (0)| 00:00:01 |
|* 13 | INDEX UNIQUE SCAN | QP_LIST_HEADERS_B_PK | 1 | | | 0 (0)| |
|* 14 | INDEX UNIQUE SCAN | QP_LIST_HEADERS_TL_PK | 1 | | | 0 (0)| |
|* 15 | TABLE ACCESS BY INDEX ROWID | QP_LIST_HEADERS_TL | 1 | 17 | | 1 (0)| 00:00:01 |
| 16 | SORT AGGREGATE | | 1 | 20 | | | |
|* 17 | FILTER | | | | | | |
|* 18 | TABLE ACCESS FULL | SPRN_INV_ITEM_IN_INT | 3 | 60 | | 1588 (1)| 00:00:20 |
|* 19 | TABLE ACCESS FULL | QP_LIST_LINES | 1 | 10 | | 641 (1)| 00:00:08 |
-------------------------------------------------------------------------------------------------------------------
1/29/17 26
Old	approaches	make	it	hard
• 1998	SQL	Tuning	(aka	traces)
– Maybe	can’t	go	back	and	run	the	SQL	again
– Maybe	run	it	again	and	it	runs	fine
• 2007	SQL	tuning	(aka	SQLT)
– Plan	looks	questionable	but	don’t	have	A-Rows
– Need	to	restore	SQLT	repo	and	write	SQLs
1/29/17 27
Old	approaches	make	it	hard
• 2007	SQL	tuning	(aka	SQLT)
– You	have	the	data,	figure	it	out
…
SELECT sql_plan_hash_value, count(*), count(distinct sql_exec_id)
FROM dba_hist_active_sess_history
WHERE sql_id = ‘…’
GROUP BY sql_plan_hash_value
…
SELECT sql_exec_id, sql_exec_start, count(*)
FROM dba_hist_active_sess_history
WHERE sql_id = ‘…’
AND sql_plan_hash_value = …
GROUP BY sql_exec_id, sql_exec_start
…
<<another	10	SQL	statements>>
1/29/17 28
1/29/17 29
Exec	plan	reported	as	a	tree
Just	read	it	left	to	right
Nodes	are	colored	
depending	on	time	sampled	
on	them.	Easy	to	spot	
bottlenecks
Easier	this	way?	J
Tree	available	also	for	
individual	executions,	easy	to	
diagnose	random	slowness
What’s	the	impact	of	SQL	X	on	DB	A?
• 1998	SQL	Tuning	(aka	traces)
– Can’t	quite	do	that
– Would	require	to	trace	every	single	SQL
• 2007	SQL	tuning	(aka	SQLT)
– Focused	on	individual	SQL,	not	much	on	overall
• Nothing	wrong	but	makes	it	hard	to	scope	impact
1/29/17 30
1/29/17 31
Significant	part	of	the	
workload,	peaks	up	to	30%
Easier	this	way?	J
1/29/17 32
System	has	10	CPUs,	up	to	
18	sessions	demanding	CPU
Easier	this	way?	J
SQL	runs	slow,	must	be	plan	issue
• 1998	SQL	Tuning	(aka	traces)
– Need	tracing	every	execution
– Might	translate	in	100s	of	files	to	review
• 2007	SQL	tuning	(aka	SQLT)
– Provides	every	info	about	the	plan	and	exec
– Main	focus	on	the	plan,	up	to	you	to	figure	out
1/29/17 33
1/29/17 34
Up	to	70%	on	Cluster,	plan	
might	be	secondary	issue,	
investigate	app	first
Easier	this	way?	J
Performance	broke,	not	sure	why
• 1998	SQL	Tuning	(aka	traces)
– Can	trace	next	exec,	no	idea	of	previous	one
• 2007	SQL	tuning	(aka	SQLT)
– Provides	info	about	all	plans,	some	slower
– No	easy	way	to	spot	if	plans	are	cause	here
– Require	you	to	parse	raw	AWR	/	ASH	info
1/29/17 35
1/29/17 36
Plan	switched	from	2210	
(good)	to	2898	(bad),	also	
plan	711	exists
Easier	this	way?	J
Same	plan	runs	randomly	slow
• 1998	SQL	Tuning	(aka	traces)
– Need	to	trace	every	exec	until	it	reproduces
• 2007	SQL	tuning	(aka	SQLT)
– Nothing	specific	about	executions
– Data	is	available	but	partially	presented	raw
– Need	to	restore	SQLT	repo	and	query	manually
1/29/17 37
1/29/17 38
Instance	4	session	1474	was	
the	one	with	slow	execution	
on	August	24
Easier	this	way?	J
Several	reports	specific	to	
that	execution
List	of	all	sampled	
executions	by	instance,	
session,	serial	with	elapsed	
time	and	many	more	info
Need	to	investigate	my	PX	execs
• 1998	SQL	Tuning	(aka	traces)
– Every	slave	generates	one	trace
– Need	to	manually	glue	them	together
• 2007	SQL	tuning	(aka	SQLT)
– Nothing	specific	about	PX	details
• No	way	to	spot	downgrades,	skewness,	etc
– Need	to	restore	SQLT	repo	and	query	manually
1/29/17 39
1/29/17 40
Little	skewness	in	
distribution
PX	is	never	easy,	but	faster	this	way?	
Number	of	sessions	executing	
the	SQL	over	time	by	wait	
event
1/29/17 41
Number	of	processes	
sampled	by	ASH
PX	is	never	easy,	but	faster	this	way?	
Execution	
DoP
PX	servers	
requested
PX	servers	
allocated
Bottom	two	
executions	are	serial
Closing	Remarks
• SQLd360	takes	few	minutes	to	run
– Can	be	executed	any	time	even	during	the	issue
• SQLd360	speeds	up	SQL	Tuning	process
– Automating	collection	and	improving	presentation
• A	new	Release	about	once	a	month
• Installs	nothing	and	it	is	free!
42
43
References
• SQLd360	introduction
– http://mauro-pagano.com/2015/02/16/sqld360-
sql-diagnostics-collection-made-faster/
• SQLd360	examples	and	download
– http://mauro.pagano.com
44
Contact	Information
• http://mauro-pagano.com
– Email
• mauro.pagano@gmail.com
– Download
• SQLd360	vYYMM (date)
– Pages
• SQLd360
45

More Related Content

PDF
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAs
PDF
Same plan different performance
PDF
Oracle statistics by example
PPTX
Understanding my database through SQL*Plus using the free tool eDB360
PDF
Oracle RAC 19c: Best Practices and Secret Internals
PPTX
Survey of some free Tools to enhance your SQL Tuning and Performance Diagnost...
PPTX
Oracle sql high performance tuning
PDF
Tanel Poder - Scripts and Tools short
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Same plan different performance
Oracle statistics by example
Understanding my database through SQL*Plus using the free tool eDB360
Oracle RAC 19c: Best Practices and Secret Internals
Survey of some free Tools to enhance your SQL Tuning and Performance Diagnost...
Oracle sql high performance tuning
Tanel Poder - Scripts and Tools short

What's hot (20)

PDF
Oracle db performance tuning
PDF
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
PDF
Oracle Performance Tuning Fundamentals
PDF
Oracle data guard for beginners
PDF
Oracle RAC 19c - the Basis for the Autonomous Database
PDF
SQL Monitoring in Oracle Database 12c
PPTX
Understanding SQL Trace, TKPROF and Execution Plan for beginners
PDF
Tanel Poder - Performance stories from Exadata Migrations
PDF
MAA Best Practices for Oracle Database 19c
PPT
Your tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
PDF
How to Use EXAchk Effectively to Manage Exadata Environments
PDF
Chasing the optimizer
PPTX
Why oracle data guard new features in oracle 18c, 19c
PPTX
Data Guard Architecture & Setup
PDF
Oracle Active Data Guard: Best Practices and New Features Deep Dive
PDF
Exadata master series_asm_2020
PDF
Oracle RAC Internals - The Cache Fusion Edition
PDF
Oracle Database performance tuning using oratop
PDF
Understanding oracle rac internals part 1 - slides
PDF
Understanding oracle rac internals part 2 - slides
Oracle db performance tuning
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Oracle Performance Tuning Fundamentals
Oracle data guard for beginners
Oracle RAC 19c - the Basis for the Autonomous Database
SQL Monitoring in Oracle Database 12c
Understanding SQL Trace, TKPROF and Execution Plan for beginners
Tanel Poder - Performance stories from Exadata Migrations
MAA Best Practices for Oracle Database 19c
Your tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
How to Use EXAchk Effectively to Manage Exadata Environments
Chasing the optimizer
Why oracle data guard new features in oracle 18c, 19c
Data Guard Architecture & Setup
Oracle Active Data Guard: Best Practices and New Features Deep Dive
Exadata master series_asm_2020
Oracle RAC Internals - The Cache Fusion Edition
Oracle Database performance tuning using oratop
Understanding oracle rac internals part 1 - slides
Understanding oracle rac internals part 2 - slides
Ad

Viewers also liked (6)

PPTX
SQL Plan Directives explained
PPTX
Adapting to Adaptive Plans on 12c
PDF
Histograms in 12c era
PPTX
SQL Tuning, takes 3 to tango
PDF
Is your SQL Exadata-aware?
PPTX
Full Table Scan: friend or foe
SQL Plan Directives explained
Adapting to Adaptive Plans on 12c
Histograms in 12c era
SQL Tuning, takes 3 to tango
Is your SQL Exadata-aware?
Full Table Scan: friend or foe
Ad

Similar to SQLd360 (20)

PPTX
Top 10 tips for Oracle performance
PPTX
Oracle performance tuning_sfsf
PPT
Top 10 Oracle SQL tuning tips
PDF
NOCOUG_201311_Fine_Tuning_Execution_Plans.pdf
PPTX
Sql and PL/SQL Best Practices I
PPT
Myth busters - performance tuning 101 2007
PPTX
Oracle Query Optimizer - An Introduction
PDF
Advanced tips for making Oracle databases faster
PDF
Find it. Fix it. Real-World SQL Tuning Cases with Karen Morton
PDF
Database & Technology 1 _ Tom Kyte _ SQL Techniques.pdf
PPTX
Oracle performance tuning for java developers
PDF
Oracle SQL tuning with SQL Plan Management
PDF
Brad McGehee Intepreting Execution Plans Mar09
PDF
Brad McGehee Intepreting Execution Plans Mar09
PPT
Sydney Oracle Meetup - access paths
PDF
Query Tuning for Database Pros & Developers
PPTX
Embarcadero In Search of Plan Stability Part 1 Webinar Slides
PDF
Indexing Strategies for Oracle Databases - Beyond the Create Index Statement
PPTX
05_DP_300T00A_Optimize.pptx
PDF
Percona live-2012-optimizer-tuning
Top 10 tips for Oracle performance
Oracle performance tuning_sfsf
Top 10 Oracle SQL tuning tips
NOCOUG_201311_Fine_Tuning_Execution_Plans.pdf
Sql and PL/SQL Best Practices I
Myth busters - performance tuning 101 2007
Oracle Query Optimizer - An Introduction
Advanced tips for making Oracle databases faster
Find it. Fix it. Real-World SQL Tuning Cases with Karen Morton
Database & Technology 1 _ Tom Kyte _ SQL Techniques.pdf
Oracle performance tuning for java developers
Oracle SQL tuning with SQL Plan Management
Brad McGehee Intepreting Execution Plans Mar09
Brad McGehee Intepreting Execution Plans Mar09
Sydney Oracle Meetup - access paths
Query Tuning for Database Pros & Developers
Embarcadero In Search of Plan Stability Part 1 Webinar Slides
Indexing Strategies for Oracle Databases - Beyond the Create Index Statement
05_DP_300T00A_Optimize.pptx
Percona live-2012-optimizer-tuning

Recently uploaded (20)

DOCX
The Five Best AI Cover Tools in 2025.docx
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PPTX
Materi-Enum-and-Record-Data-Type (1).pptx
PPTX
AIRLINE PRICE API | FLIGHT API COST |
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
QAware_Mario-Leander_Reimer_Architecting and Building a K8s-based AI Platform...
PPTX
Transform Your Business with a Software ERP System
PDF
Build Multi-agent using Agent Development Kit
PDF
top salesforce developer skills in 2025.pdf
PPTX
ai tools demonstartion for schools and inter college
PDF
A REACT POMODORO TIMER WEB APPLICATION.pdf
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
ISO 45001 Occupational Health and Safety Management System
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
PTS Company Brochure 2025 (1).pdf.......
PPT
Introduction Database Management System for Course Database
PPTX
Presentation of Computer CLASS 2 .pptx
PPTX
FLIGHT TICKET RESERVATION SYSTEM | FLIGHT BOOKING ENGINE API
PDF
medical staffing services at VALiNTRY
PDF
Multi-factor Authentication (MFA) requirement for Microsoft 365 Admin Center_...
The Five Best AI Cover Tools in 2025.docx
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
Materi-Enum-and-Record-Data-Type (1).pptx
AIRLINE PRICE API | FLIGHT API COST |
VVF-Customer-Presentation2025-Ver1.9.pptx
QAware_Mario-Leander_Reimer_Architecting and Building a K8s-based AI Platform...
Transform Your Business with a Software ERP System
Build Multi-agent using Agent Development Kit
top salesforce developer skills in 2025.pdf
ai tools demonstartion for schools and inter college
A REACT POMODORO TIMER WEB APPLICATION.pdf
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
ISO 45001 Occupational Health and Safety Management System
How to Migrate SBCGlobal Email to Yahoo Easily
PTS Company Brochure 2025 (1).pdf.......
Introduction Database Management System for Course Database
Presentation of Computer CLASS 2 .pptx
FLIGHT TICKET RESERVATION SYSTEM | FLIGHT BOOKING ENGINE API
medical staffing services at VALiNTRY
Multi-factor Authentication (MFA) requirement for Microsoft 365 Admin Center_...

SQLd360