SlideShare uma empresa Scribd logo
1 de 53
Baixar para ler offline
Same	Plan
Different	Performance
Mauro	Pagano
SQL	is	slower….
• Same	SQL	experiences	different	performance	
in	systems	that	are	identical	(or	supposed	to)
• First	check	the	execution	plan
• Most	of	the	time	plan	is	different,	address	it
• But	what	if	the	plan	is	the	same?	
2
CBO	is	innocent	(this	time,	maybe)
• Exec	plan	is	where	CBO’s	job	end		(kind	of)
• Same	plan	means	CBO	“worked”	the	same
• Doesn’t	mean	everything	else	IS the	same
• Shift	focus	on	next	step,	SQL	execution
3
Apples	vs oranges?
• Make	sure	the	comparison	is	fair	(data)
• All	external	factors	should	be	similar
– CPU	should	be	similar
– IO	should	be	similar
– Memory	should	be	similar
4
“Everything	is	the	same!”
• Plan,	data	and	hardware	match,	now	what?
• Dig	into	how	the	SQL	is	executed
• Wait	events	and	session	statistics
• Factors
– configuration,	storage	layout,	load
5
Old	friends	get-together
• Wait	events
– Do	they	match?	
– Are	they	close	in	cardinality?
– Do	we	spend	the	same	time	on	them?
• Session	statistics
– Do	they	match?
– Are	they	close	in	values?
6
Back	to	the	plan	for	a	second
• Exec	plan	is	made	of	lots	of	small	steps
• Each	one	produces/handles/consumes	rows	
• Same	behaviors	in	short	and	long	plans
• Keep	it	simple,	focus	on	the	step	
• Remove	the	noise	if	possible	(reduce	TC)
7
Each	scenario	is	a	quiz
• SQL	is	provided
• Changes	to	the	initial	setup	are	disclosed
• Each	run	in	one	environment
• Identify	what’s	different	and	why
8
Setup
• Linux	x86-64,	11.2.0.3
• 1	table,	1M	rows,	3	columns,	no	index
– N1	unique
– N2	100	NDV
– C1	100chars	long	padded	string
• Identical	hardware,	same	DDL	to	create	table
• Controlled	environments	to	isolate	behavior
• Simplest	SQL	to	reproduce	desired	behavior
9
Scenario	#1
• SQL
– select	/*+	INDEX(TEST1M)	*/	count(*)	
from	test1m	
where	n1	between	1	and	1000000
• Environment
– Added	index	on	N1
10
Scenario	#1	– Run	(A)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.31 0.45 2228 2228 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.32 0.45 2228 2228 0 1
Rows (1st) Rows (avg) Rows (max) Row Source Operation
---------- ---------- ---------- ---------------------------------------------------
1 1 1 SORT AGGREGATE (cr=2228 pr=2228 pw=0 time=451619 us)
1000000 1000000 1000000 INDEX RANGE SCAN TEST1M_IDX (cr=2228 pr=2228
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
db file sequential read 2228 0.00 0.15
11
Scenario	#1	– Run	(B)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.07 0.08 0 2228 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.08 0.08 0 2228 0 1
Rows (1st) Rows (avg) Rows (max) Row Source Operation
---------- ---------- ---------- ---------------------------------------------------
1 1 1 SORT AGGREGATE (cr=2228 pr=0 pw=0 time=80038 us)
1000000 1000000 1000000 INDEX RANGE SCAN TEST1M_IDX (cr=2228 pr=0 pw=0
12
Scenario	#1	Solution
• Buffer	Cache	cold/warm
• (Part	of)	the	data	already	in	memory
• Reduced	number	of	physical	reads	(pr)
• Faster	performance	because	less	reads
• Number	of	(same)	wait	events	is	lower
• Isolated	environment	likely	to	read	more
13
Scenario	#2
• SQL
– select	/*+	FULL(TEST1M)	*/	count(*)	
from	test1m	
• Environment
– No	changes	from	original	setup
14
Scenario	#2	– Run	(A)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.01 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.57 1.51 28574 28584 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.57 1.52 28574 28584 0 1
Rows (1st) Rows (avg) Rows (max) Row Source Operation
---------- ---------- ---------- ---------------------------------------------------
1 1 1 SORT AGGREGATE (cr=28584 pr=28574 pw=0 time=1513999 us)
1000000 1000000 1000000 TABLE ACCESS FULL TEST1M (cr=28584 pr=28574
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
db file sequential read 1 0.00 0.00
db file scattered read 240 0.02 1.07
15
Scenario	#2	– Run	(B)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 1.04 2.42 14286 28583 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 1.04 2.42 14286 28583 0 1
Rows (1st) Rows (avg) Rows (max) Row Source Operation
---------- ---------- ---------- ---------------------------------------------------
1 1 1 SORT AGGREGATE (cr=28583 pr=14286 pw=0 time=2424726 us)
1000000 1000000 1000000 TABLE ACCESS FULL TEST1M (cr=28583 pr=14286
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
db file sequential read 5732 0.01 0.89
db file scattered read 4277 0.00 0.75
16
Scenario	#2	– Run	(A)	- Waits
WAIT	#140245916217600:	nam='db file	scattered	read'	ela=	4834	file#=26	block#=16002	blocks=128
WAIT	#140245916217600:	nam='db file	scattered	read'	ela=	4020	file#=26	block#=16130	blocks=128
WAIT	#140245916217600:	nam='db file	scattered	read'	ela=	2452	file#=26	block#=16258	blocks=128
WAIT	#140245916217600:	nam='db file	scattered	read'	ela=	8712	file#=26	block#=16386	blocks=128	
WAIT	#140245916217600:	nam='db file	scattered	read'	ela=	6417	file#=26	block#=16514	blocks=128
WAIT	#140245916217600:	nam='db file	scattered	read'	ela=	2267	file#=26	block#=16642	blocks=128
WAIT	#140245916217600:	nam='db file	scattered	read'	ela=	2637	file#=26	block#=16770	blocks=128
WAIT	#140245916217600:	nam='db file	scattered	read'	ela=	2304	file#=26	block#=16898	blocks=128
WAIT	#140245916217600:	nam='db file	scattered	read'	ela=	1809	file#=26	block#=17026	blocks=128
WAIT	#140245916217600:	nam='db file	scattered	read'	ela=	2661	file#=26	block#=17154	blocks=128
17
Scenario	#2	– Run	(B)	- Waits
WAIT	#140245916165224:	nam='db file	sequential	read'	ela=	124	file#=26	block#=16002	blocks=1
WAIT	#140245916165224:	nam='db file	scattered	read'	ela=	139	file#=26	block#=16004	blocks=2
WAIT	#140245916165224:	nam='db file	sequential	read'	ela=	117	file#=26	block#=16007	blocks=1
….<<another	38	waits	here>>
WAIT	#140245916165224:	nam='db file	sequential	read'	ela=	132	file#=26	block#=16113	blocks=1
WAIT	#140245916165224:	nam='db file	sequential	read'	ela=	123	file#=26	block#=16116	blocks=1
WAIT	#140245916165224:	nam='db file	scattered	read'	ela=	142	file#=26	block#=16118	blocks=2
WAIT	#140245916165224:	nam='db file	scattered	read'	ela=	141	file#=26	block#=16121	blocks=2
WAIT	#140245916165224:	nam='db file	scattered	read'	ela=	135	file#=26	block#=16124	blocks=2
WAIT	#140245916165224:	nam='db file	sequential	read'	ela=	119	file#=26	block#=16127	blocks=1
18
Scenario	#2	Solution
• Buffer	cache	status	(cold/warm)
• (Part	of)	the	data	already	in	memory
• Reduced	number	of	physical	reads	(pr)
• Number	of	(same)	wait	events	is	higher
• Wait	events	details	help	track	it	down
– Non-contiguous	blocks	read
• Slower	performance	because	smaller	reads
19
Scenario	#3
• SQL
– select	/*+	FULL(TEST1M)	*/	count(*)	
from	test1m	
• Environment
– No	changes	
– BC	warm
20
Scenario	#3	– Run	(A)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.92 2.96 14286 28583 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.92 2.96 14286 28583 0 1
Rows (1st) Rows (avg) Rows (max) Row Source Operation
---------- ---------- ---------- ---------------------------------------------------
1 1 1 SORT AGGREGATE (cr=28583 pr=14286 pw=0 time=2967930 us)
1000000 1000000 1000000 TABLE ACCESS FULL TEST1M (cr=28583 pr=14286
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
db file sequential read 5732 0.10 1.17
db file scattered read 4277 0.28 1.13
21
Scenario	#3	– Run	(B)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.11 1.01 28573 28575 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.11 1.02 28573 28575 0 1
Rows (1st) Rows (avg) Rows (max) Row Source Operation
---------- ---------- ---------- ---------------------------------------------------
1 1 1 SORT AGGREGATE (cr=28575 pr=28573 pw=0 time=1019952 us)
1000000 1000000 1000000 TABLE ACCESS FULL TEST1M (cr=28575 pr=28573
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
enq: KO - fast object checkpoint 2 0.00 0.00
direct path read 179 0.03 0.90
22
Scenario	#3	– Solution
• Buffered	vs Direct	Path	reads	(different	waits	too)
• (Part	of)	the	data	already	in	memory
• Direct	Path	
– skips	Buffer	Cache	and	reads	whole	table	every	time
– consistent	performance	
– number	of	wait	events	is	consistent
• Buffered	vs Direct	Path	decision	is	made	AFTER	
plan	selection	(several	criteria)
23
Scenario	#4
• SQL
– select	/*+	FULL(TEST1M)	*/	count(*)	
from	test1m	
• Environment
– No	changes	
– BC	cold
24
Scenario	#4	– Run	(A)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.01 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.57 3.08 15872 15884 1 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.57 3.10 15872 15884 1 1
Rows (1st) Rows (avg) Rows (max) Row Source Operation
---------- ---------- ---------- ---------------------------------------------------
1 1 1 SORT AGGREGATE (cr=15884 pr=15872 pw=0 time=3086869 us)
1000000 1000000 1000000 TABLE ACCESS FULL TEST1M (cr=15884 pr=15872
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
db file scattered read 2005 0.05 2.53
25
Scenario	#4	– Run	(B)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.32 1.66 15872 15881 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.32 1.66 15872 15881 0 1
Rows (1st) Rows (avg) Rows (max) Row Source Operation
---------- ---------- ---------- ---------------------------------------------------
1 1 1 SORT AGGREGATE (cr=15881 pr=15872 pw=0 time=1660864 us)
1000000 1000000 1000000 TABLE ACCESS FULL TEST1M (cr=15881 pr=15872
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
db file scattered read 141 0.05 1.41
26
Scenario	#4	– Run	(A)	- Waits
WAIT	#139702845969088:	nam='db file	scattered	read'	ela=	265	file#=25	block#=306	blocks=8
WAIT	#139702845969088:	nam='db file	scattered	read'	ela=	257	file#=25	block#=314	blocks=8
WAIT	#139702845969088:	nam='db file	scattered	read'	ela=	259	file#=25	block#=322	blocks=8
WAIT	#139702845969088:	nam='db file	scattered	read'	ela=	254	file#=25	block#=330	blocks=8
…..
WAIT	#139702845969088:	nam='db file	scattered	read'	ela=	217	file#=25	block#=378	blocks=6	
WAIT	#139702845969088:	nam='db file	scattered	read'	ela=	270	file#=25	block#=386	blocks=8	
WAIT	#139702845969088:	nam='db file	scattered	read'	ela=	283	file#=25	block#=394	blocks=8	
WAIT	#139702845969088:	nam='db file	scattered	read'	ela=	263	file#=25	block#=402	blocks=8
27
Scenario	#4	– Run	(B)	- Waits
WAIT	#139702846026760:	nam='db file	scattered	read'	ela=	13508	file#=25	block#=258	blocks=128
WAIT	#139702846026760:	nam='db file	scattered	read'	ela=	9016	file#=25	block#=386	blocks=128
28
Scenario	#4	– Solution	1
• Different	db_file_multiblock_read_count value
• Same	number	of	blocks	read	from	disk
• Number	of	(same)	wait	events	is	higher
• Wait	events	details	help	track	it	down
– Contiguous	blocks	read
• Slower	performance	because	smaller	reads
29
Scenario	#4	– Solution	2
• Different	extent	size	(64k	vs 1M)
• Same	number	of	blocks	read	from	disk
• Number	of	(same)	wait	events	is	higher
• Wait	events	details	help	track	it	down
– Contiguous	blocks	read
• Same	params/stats	but	different	storage	org
• Slower	performance	because	smaller	reads
30
Scenario	#5
• SQL
– select	/*+	FULL(TEST1M)	*/	count(*)	
from	test1m	
• Env changes
– No	changes	
– BC	cold,	MBRC	and	extent	are	identical
31
Scenario	#5	– Run	(A)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.26 0.72 14285 14297 1 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.27 0.72 14285 14297 1 1
Rows (1st) Rows (avg) Rows (max) Row Source Operation
---------- ---------- ---------- ---------------------------------------------------
1 1 1 SORT AGGREGATE (cr=14297 pr=14285 pw=0 time=723883 us)
1000000 1000000 1000000 TABLE ACCESS FULL TEST1M (cr=14297 pr=14285
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
db file scattered read 128 0.04 0.51
32
Scenario	#5	– Run	(B)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.44 1.29 28574 28586 1 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.44 1.29 28574 28586 1 1
Rows (1st) Rows (avg) Rows (max) Row Source Operation
---------- ---------- ---------- ---------------------------------------------------
1 1 1 SORT AGGREGATE (cr=28586 pr=28574 pw=0 time=1291333 us)
1000000 1000000 1000000 TABLE ACCESS FULL TEST1M (cr=28586 pr=28574
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
db file scattered read 240 0.04 0.95
33
Scenario	#5	– Solution	1
• Different	PCTFREE	(0	vs 50)
• Higher	number	of	blocks	read	for	same	data
• Reads	are	of	the	same	size	hence	more	reads
• Data	is	more	spread	out,	room	for	changes
• Slower	performance	because	more	reads
34
Scenario	#5	– Solution	2
• Empty	blocks	below	HWM
• Higher	number	of	blocks	read	for	same	data
• Reads	are	of	the	same	size	hence	more	reads
• Data	has	been	deleted,	FTS	reads	everything
• Slower	performance	because	more	reads
35
Scenario	#6	
• SQL
– select	/*+	FULL(TEST1M)	*/	count(*)	
from	test1m	
• Env changes
– No	changes
– BC	cold,	MBRC,	PCTFREE	and	extent	are	identical
36
Scenario	#6	– Run	(A)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.44 1.29 28574 28586 1 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.44 1.29 28574 28586 1 1
Rows (1st) Rows (avg) Rows (max) Row Source Operation
---------- ---------- ---------- ---------------------------------------------------
1 1 1 SORT AGGREGATE (cr=28586 pr=28574 pw=0 time=1291333 us)
1000000 1000000 1000000 TABLE ACCESS FULL TEST1M (cr=28586 pr=28574
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
db file scattered read 240 0.04 0.95
37
Scenario	#6	– Run	(B)
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.73 2.49 28803 58584 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.74 2.49 28803 58584 0 1
Rows (1st) Rows (avg) Rows (max) Row Source Operation
---------- ---------- ---------- ---------------------------------------------------
1 1 1 SORT AGGREGATE (cr=58584 pr=28803 pw=0 time=2492596 us)
1000000 1000000 1000000 TABLE ACCESS FULL TEST1M (cr=58584 pr=28803
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
db file scattered read 240 0.23 1.73
cell single block physical read 230 0.01 0.06
38
Scenario	#6	– Waits	and	SesStats
• Wait	events	show	
– single	block	reads	from	UNDO	tbs for	obj#=0
WAIT	#140029131327704:	nam='db file	scattered	read'	ela=	15412	file#=26	block#=15618	blocks=128	obj#=74828	
WAIT	#140029131327704:	nam='cell	single	block	physical	read'	ela=	220	…	bytes=8192	obj#=0	
WAIT	#140029131327704:	nam='db file	scattered	read'	ela=	11786	file#=26	block#=15746	blocks=128	obj#=74828
WAIT	#140029131327704:	nam='cell	single	block	physical	read'	ela=	233	…	bytes=8192	obj#=0	
WAIT	#140029131327704:	nam='db file	scattered	read'	ela=	5938	file#=26	block#=15874	blocks=128	obj#=74828
WAIT	#140029131327704:	nam='cell	single	block	physical	read'	ela=	224	…	bytes=8192	obj#=0	
WAIT	#140029131327704:	nam='db file	scattered	read'	ela=	12162	file#=26	block#=16002	blocks=128	obj#=74828
• v$sesstat shows	high
– data	blocks	consistent	reads	- undo	records	applied
39
Scenario	#6 - Solution
• Different	concurrency/workload
• Higher	number	of	blocks	read	for	same	data
• Waits	->	reads	from	UNDO	tbs
• SesStats ->	UNDO	records	applied
• Slower	performance	because	more	reads	+	
more	work	to	recreate	the	correct	image
40
Scenario	#7
• SQL
– select	/*	1st	run	*/	n1,c1	
from	test1m	
where	n1	in	(1,1000,5000)
• Env changes
– Index	on	TEST1M(N1)
– BC	cold,	MBRC,	PCTFREE	and	extent	are	identical
– No	concurrency	at	the	time	SQL	is	executed
41
Scenario	#7	– Why	so	many	cr/pr?
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.75 11 18 0 3
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.00 0.75 11 18 0 3
Rows (1st) Rows (avg) Rows (max) Row Source Operation
---------- ---------- ---------- ---------------------------------------------------
3 3 3 INLIST ITERATOR (cr=18 pr=11 pw=0 time=235681 us)
3 3 3 TABLE ACCESS BY INDEX ROWID TEST1M (cr=18 pr=11
3 3 3 INDEX RANGE SCAN TEST1M_IDX (cr=9 pr=5 pw=0
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
db file sequential read 11 0.18 0.52
42
Scenario	#7	– Waits	and	SesStats
• Wait	events	show	
– single	block	reads	from	data	tbs,	same	obj#
WAIT	#140…:	nam='db file	sequential	read'	ela=	7414	file#=26	block#=2356	blocks=1	obj#=75022	
WAIT	#140…:	nam='db file	sequential	read'	ela=	41395	file#=26	block#=131	blocks=1	obj#=74828	
WAIT	#140…:	nam='db file	sequential	read'	ela=	181594	file#=26	block#=78403	blocks=1	obj#=74828
• v$sesstat shows	high
– table	fetch	continued	row
43
Scenario	#7	- Solution
• Row	migration,	index	points	to	original	rowid
• Higher	number	of	blocks	read	for	same	data
• Waits	->	reads	are	from	data	tbs
• SesStats ->	table	fetch	continued	row
• Slower	performance	because	more	reads	+	
more	work	to	find	all	the	row	pieces
• Similar	behavior	happens	with	chained	rows
44
Scenario	#8
• SQL
– select	/*	2nd	run	*/	n1,c1,	ora_rowscn
from	test1m	
where	rownum <=	5000
• Env changes
– Index	on	TEST1M(N1)
– BC	cold,	MBRC,	PCTFREE	and	extent	are	identical
– No	concurrency	at	the	time	SQL	is	executed
45
Scenario	#8	- Why	so	many	seq read?
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 6 0.03 0.22 393 5378 0 5000
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 8 0.03 0.22 393 5378 0 5000
Rows (1st) Rows (avg) Rows (max) Row Source Operation
---------- ---------- ---------- -------------------------------------------
5000 5000 5000 COUNT STOPKEY (cr=5378 pr=393 pw=0 time=91193
5000 5000 5000 TABLE ACCESS FULL TEST1M (cr=5378 pr=393
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
db file sequential read 381 0.00 0.19
db file scattered read 2 0.00 0.00
46
Scenario	#8	– Waits	and	SesStats
• Wait	events	show	
– single	block	reads	from	data	tbs,	same	obj#
WAIT	#1405…:	nam='db file	scattered	read'	ela=	6434	file#=26	block#=132	blocks=4	obj#=74828	
WAIT	#1405…:	nam='db file	sequential	read'	ela=	193	file#=26	block#=78670	blocks=1	obj#=74828	
WAIT	#1405…:	nam='db file	sequential	read'	ela=	182	file#=26	block#=78686	blocks=1	obj#=74828	
WAIT	#1405…:	nam='db file	sequential	read'	ela=	3445	file#=26	block#=7890	blocks=1	obj#=74828	
• v$sesstat shows	high
– table	fetch	continued	row
47
Scenario	#8	- Solution
• Row	migration,	pseudo	col	needs	row	header
• Higher	number	of	blocks	read	for	same	data
• Waits	->	reads	are	from	data	tbs
• SesStats ->	table	fetch	continued	row
• Slower	performance	because	more	reads	+	
more	work	to	find	all	the	row	pieces
• Similar	behavior	happens	with	chained	rows
48
Other	things	to	consider
• Same	PHV	with	small	differences
– Predicate	ordering
– Column	projection
• Exadata Optimizations
– Exadata Smart	Flash	Cache
– Storage	indexes
• External	to	the	database
– File	system	/	SAN	/	Disk	caching
– Read-ahead	optimizations	
49
Conclusions
• Same	plan	can	still	run	differently
• Storage	organization	and	concurrency	impact
• Fix	one	scenario	can	introduce	another,	ie.	
– low	PCTFREE	higher	chance	of	row	migration
– high	caching	slows	down	buffered	mreads
• Find	a	balance	to	achieve	optimal	performance
50
51
References
• 'DB_FILE_MULTIBLOCK_READ_COUNT'	AND	EXTENTS	
MANAGEMENT	(Doc	ID	181272.1)
• Higher	'direct	path	read'	Waits	in	11g	when	
Compared	to	10g	(Doc	ID	793845.1)
• Why	Is	My	Query	Sometimes	Slower	Than	Other	
Times	with	Higher	Consistent	Gets	Although	No	
Change	in	Execution	Plan?	(Doc	ID	1558349.1)
• Row	Chaining	and	Row	Migration	(Doc	ID	122020.1)
52
Contact	Information
• http://mauro-pagano.com
– Email
• mauro.pagano@gmail.com
– Download
• SQLd360	vYYMM (date)
– Pages
• SQLd360
53

Mais conteúdo relacionado

Mais procurados

Oracle statistics by example
Oracle statistics by exampleOracle statistics by example
Oracle statistics by exampleMauro Pagano
 
Adapting and adopting spm v04
Adapting and adopting spm v04Adapting and adopting spm v04
Adapting and adopting spm v04Carlos Sierra
 
Tanel Poder - Scripts and Tools short
Tanel Poder - Scripts and Tools shortTanel Poder - Scripts and Tools short
Tanel Poder - Scripts and Tools shortTanel Poder
 
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentalsDB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentalsJohn Beresniewicz
 
Understanding my database through SQL*Plus using the free tool eDB360
Understanding my database through SQL*Plus using the free tool eDB360Understanding my database through SQL*Plus using the free tool eDB360
Understanding my database through SQL*Plus using the free tool eDB360Carlos Sierra
 
Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...
Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...
Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...Carlos Sierra
 
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And WhatPerformance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And Whatudaymoogala
 
Understanding oracle rac internals part 2 - slides
Understanding oracle rac internals   part 2 - slidesUnderstanding oracle rac internals   part 2 - slides
Understanding oracle rac internals part 2 - slidesMohamed Farouk
 
SQL Monitoring in Oracle Database 12c
SQL Monitoring in Oracle Database 12cSQL Monitoring in Oracle Database 12c
SQL Monitoring in Oracle Database 12cTanel Poder
 
SQL Plan Directives explained
SQL Plan Directives explainedSQL Plan Directives explained
SQL Plan Directives explainedMauro Pagano
 
Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle Kyle Hailey
 
Oracle sql high performance tuning
Oracle sql high performance tuningOracle sql high performance tuning
Oracle sql high performance tuningGuy Harrison
 
Oracle RAC Internals - The Cache Fusion Edition
Oracle RAC Internals - The Cache Fusion EditionOracle RAC Internals - The Cache Fusion Edition
Oracle RAC Internals - The Cache Fusion EditionMarkus Michalewicz
 
Tanel Poder - Performance stories from Exadata Migrations
Tanel Poder - Performance stories from Exadata MigrationsTanel Poder - Performance stories from Exadata Migrations
Tanel Poder - Performance stories from Exadata MigrationsTanel Poder
 
Awr + 12c performance tuning
Awr + 12c performance tuningAwr + 12c performance tuning
Awr + 12c performance tuningAiougVizagChapter
 
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 1
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 1Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 1
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 1Tanel Poder
 
Christo kutrovsky oracle, memory & linux
Christo kutrovsky   oracle, memory & linuxChristo kutrovsky   oracle, memory & linux
Christo kutrovsky oracle, memory & linuxKyle Hailey
 
Understanding SQL Trace, TKPROF and Execution Plan for beginners
Understanding SQL Trace, TKPROF and Execution Plan for beginnersUnderstanding SQL Trace, TKPROF and Execution Plan for beginners
Understanding SQL Trace, TKPROF and Execution Plan for beginnersCarlos Sierra
 
Oracle Performance Tuning Fundamentals
Oracle Performance Tuning FundamentalsOracle Performance Tuning Fundamentals
Oracle Performance Tuning FundamentalsCarlos Sierra
 

Mais procurados (20)

Oracle statistics by example
Oracle statistics by exampleOracle statistics by example
Oracle statistics by example
 
Adapting and adopting spm v04
Adapting and adopting spm v04Adapting and adopting spm v04
Adapting and adopting spm v04
 
AWR and ASH Deep Dive
AWR and ASH Deep DiveAWR and ASH Deep Dive
AWR and ASH Deep Dive
 
Tanel Poder - Scripts and Tools short
Tanel Poder - Scripts and Tools shortTanel Poder - Scripts and Tools short
Tanel Poder - Scripts and Tools short
 
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentalsDB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals
 
Understanding my database through SQL*Plus using the free tool eDB360
Understanding my database through SQL*Plus using the free tool eDB360Understanding my database through SQL*Plus using the free tool eDB360
Understanding my database through SQL*Plus using the free tool eDB360
 
Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...
Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...
Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...
 
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And WhatPerformance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
 
Understanding oracle rac internals part 2 - slides
Understanding oracle rac internals   part 2 - slidesUnderstanding oracle rac internals   part 2 - slides
Understanding oracle rac internals part 2 - slides
 
SQL Monitoring in Oracle Database 12c
SQL Monitoring in Oracle Database 12cSQL Monitoring in Oracle Database 12c
SQL Monitoring in Oracle Database 12c
 
SQL Plan Directives explained
SQL Plan Directives explainedSQL Plan Directives explained
SQL Plan Directives explained
 
Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle
 
Oracle sql high performance tuning
Oracle sql high performance tuningOracle sql high performance tuning
Oracle sql high performance tuning
 
Oracle RAC Internals - The Cache Fusion Edition
Oracle RAC Internals - The Cache Fusion EditionOracle RAC Internals - The Cache Fusion Edition
Oracle RAC Internals - The Cache Fusion Edition
 
Tanel Poder - Performance stories from Exadata Migrations
Tanel Poder - Performance stories from Exadata MigrationsTanel Poder - Performance stories from Exadata Migrations
Tanel Poder - Performance stories from Exadata Migrations
 
Awr + 12c performance tuning
Awr + 12c performance tuningAwr + 12c performance tuning
Awr + 12c performance tuning
 
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 1
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 1Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 1
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 1
 
Christo kutrovsky oracle, memory & linux
Christo kutrovsky   oracle, memory & linuxChristo kutrovsky   oracle, memory & linux
Christo kutrovsky oracle, memory & linux
 
Understanding SQL Trace, TKPROF and Execution Plan for beginners
Understanding SQL Trace, TKPROF and Execution Plan for beginnersUnderstanding SQL Trace, TKPROF and Execution Plan for beginners
Understanding SQL Trace, TKPROF and Execution Plan for beginners
 
Oracle Performance Tuning Fundamentals
Oracle Performance Tuning FundamentalsOracle Performance Tuning Fundamentals
Oracle Performance Tuning Fundamentals
 

Semelhante a Same plan different performance

SQL Tuning, takes 3 to tango
SQL Tuning, takes 3 to tangoSQL Tuning, takes 3 to tango
SQL Tuning, takes 3 to tangoMauro Pagano
 
PostgreSQL Portland Performance Practice Project - Database Test 2 Tuning
PostgreSQL Portland Performance Practice Project - Database Test 2 TuningPostgreSQL Portland Performance Practice Project - Database Test 2 Tuning
PostgreSQL Portland Performance Practice Project - Database Test 2 TuningMark Wong
 
Metadata Matters
Metadata MattersMetadata Matters
Metadata Mattersafa reg
 
Oracle Database Performance Tuning Basics
Oracle Database Performance Tuning BasicsOracle Database Performance Tuning Basics
Oracle Database Performance Tuning Basicsnitin anjankar
 
AWR Ambiguity: Performance reasoning when the numbers don't add up
AWR Ambiguity: Performance reasoning when the numbers don't add upAWR Ambiguity: Performance reasoning when the numbers don't add up
AWR Ambiguity: Performance reasoning when the numbers don't add upJohn Beresniewicz
 
Compression ow2009 r2
Compression ow2009 r2Compression ow2009 r2
Compression ow2009 r2carldudley
 
Analyze database system using a 3 d method
Analyze database system using a 3 d methodAnalyze database system using a 3 d method
Analyze database system using a 3 d methodAjith Narayanan
 
Analyzing SQL Traces generated by EVENT 10046.pptx
Analyzing SQL Traces generated by EVENT 10046.pptxAnalyzing SQL Traces generated by EVENT 10046.pptx
Analyzing SQL Traces generated by EVENT 10046.pptxssuserbad8d3
 
zen and the art of SQL optimization
zen and the art of SQL optimizationzen and the art of SQL optimization
zen and the art of SQL optimizationKaren Morton
 
Thomas+Niewel+ +Oracletuning
Thomas+Niewel+ +OracletuningThomas+Niewel+ +Oracletuning
Thomas+Niewel+ +Oracletuningafa reg
 
Oracle Performance Tuning DE(v1.2)-part2.ppt
Oracle Performance Tuning DE(v1.2)-part2.pptOracle Performance Tuning DE(v1.2)-part2.ppt
Oracle Performance Tuning DE(v1.2)-part2.pptVenugopalChattu1
 
Database & Technology 1 _ Tom Kyte _ SQL Techniques.pdf
Database & Technology 1 _ Tom Kyte _ SQL Techniques.pdfDatabase & Technology 1 _ Tom Kyte _ SQL Techniques.pdf
Database & Technology 1 _ Tom Kyte _ SQL Techniques.pdfInSync2011
 
Oracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmastersOracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmastersKyle Hailey
 
Troubleshooting Complex Oracle Performance Problems with Tanel Poder
Troubleshooting Complex Oracle Performance Problems with Tanel PoderTroubleshooting Complex Oracle Performance Problems with Tanel Poder
Troubleshooting Complex Oracle Performance Problems with Tanel PoderTanel Poder
 
Hailey_Database_Performance_Made_Easy_through_Graphics.pdf
Hailey_Database_Performance_Made_Easy_through_Graphics.pdfHailey_Database_Performance_Made_Easy_through_Graphics.pdf
Hailey_Database_Performance_Made_Easy_through_Graphics.pdfcookie1969
 

Semelhante a Same plan different performance (20)

SQL Tuning, takes 3 to tango
SQL Tuning, takes 3 to tangoSQL Tuning, takes 3 to tango
SQL Tuning, takes 3 to tango
 
PostgreSQL Portland Performance Practice Project - Database Test 2 Tuning
PostgreSQL Portland Performance Practice Project - Database Test 2 TuningPostgreSQL Portland Performance Practice Project - Database Test 2 Tuning
PostgreSQL Portland Performance Practice Project - Database Test 2 Tuning
 
Metadata Matters
Metadata MattersMetadata Matters
Metadata Matters
 
SAV
SAVSAV
SAV
 
Oracle Database Performance Tuning Basics
Oracle Database Performance Tuning BasicsOracle Database Performance Tuning Basics
Oracle Database Performance Tuning Basics
 
AWR Ambiguity: Performance reasoning when the numbers don't add up
AWR Ambiguity: Performance reasoning when the numbers don't add upAWR Ambiguity: Performance reasoning when the numbers don't add up
AWR Ambiguity: Performance reasoning when the numbers don't add up
 
Compression ow2009 r2
Compression ow2009 r2Compression ow2009 r2
Compression ow2009 r2
 
Analyze database system using a 3 d method
Analyze database system using a 3 d methodAnalyze database system using a 3 d method
Analyze database system using a 3 d method
 
Analyzing SQL Traces generated by EVENT 10046.pptx
Analyzing SQL Traces generated by EVENT 10046.pptxAnalyzing SQL Traces generated by EVENT 10046.pptx
Analyzing SQL Traces generated by EVENT 10046.pptx
 
zen and the art of SQL optimization
zen and the art of SQL optimizationzen and the art of SQL optimization
zen and the art of SQL optimization
 
Thomas+Niewel+ +Oracletuning
Thomas+Niewel+ +OracletuningThomas+Niewel+ +Oracletuning
Thomas+Niewel+ +Oracletuning
 
Rmoug ashmaster
Rmoug ashmasterRmoug ashmaster
Rmoug ashmaster
 
Contiguous
ContiguousContiguous
Contiguous
 
Autoextend
AutoextendAutoextend
Autoextend
 
Oracle Performance Tuning DE(v1.2)-part2.ppt
Oracle Performance Tuning DE(v1.2)-part2.pptOracle Performance Tuning DE(v1.2)-part2.ppt
Oracle Performance Tuning DE(v1.2)-part2.ppt
 
Database & Technology 1 _ Tom Kyte _ SQL Techniques.pdf
Database & Technology 1 _ Tom Kyte _ SQL Techniques.pdfDatabase & Technology 1 _ Tom Kyte _ SQL Techniques.pdf
Database & Technology 1 _ Tom Kyte _ SQL Techniques.pdf
 
SQLQueries
SQLQueriesSQLQueries
SQLQueries
 
Oracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmastersOracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmasters
 
Troubleshooting Complex Oracle Performance Problems with Tanel Poder
Troubleshooting Complex Oracle Performance Problems with Tanel PoderTroubleshooting Complex Oracle Performance Problems with Tanel Poder
Troubleshooting Complex Oracle Performance Problems with Tanel Poder
 
Hailey_Database_Performance_Made_Easy_through_Graphics.pdf
Hailey_Database_Performance_Made_Easy_through_Graphics.pdfHailey_Database_Performance_Made_Easy_through_Graphics.pdf
Hailey_Database_Performance_Made_Easy_through_Graphics.pdf
 

Último

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 

Último (20)

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 

Same plan different performance

  • 3. CBO is innocent (this time, maybe) • Exec plan is where CBO’s job end (kind of) • Same plan means CBO “worked” the same • Doesn’t mean everything else IS the same • Shift focus on next step, SQL execution 3
  • 4. Apples vs oranges? • Make sure the comparison is fair (data) • All external factors should be similar – CPU should be similar – IO should be similar – Memory should be similar 4
  • 5. “Everything is the same!” • Plan, data and hardware match, now what? • Dig into how the SQL is executed • Wait events and session statistics • Factors – configuration, storage layout, load 5
  • 6. Old friends get-together • Wait events – Do they match? – Are they close in cardinality? – Do we spend the same time on them? • Session statistics – Do they match? – Are they close in values? 6
  • 7. Back to the plan for a second • Exec plan is made of lots of small steps • Each one produces/handles/consumes rows • Same behaviors in short and long plans • Keep it simple, focus on the step • Remove the noise if possible (reduce TC) 7
  • 8. Each scenario is a quiz • SQL is provided • Changes to the initial setup are disclosed • Each run in one environment • Identify what’s different and why 8
  • 9. Setup • Linux x86-64, 11.2.0.3 • 1 table, 1M rows, 3 columns, no index – N1 unique – N2 100 NDV – C1 100chars long padded string • Identical hardware, same DDL to create table • Controlled environments to isolate behavior • Simplest SQL to reproduce desired behavior 9
  • 11. Scenario #1 – Run (A) call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 1 0.00 0.00 0 0 0 0 Fetch 2 0.31 0.45 2228 2228 0 1 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 4 0.32 0.45 2228 2228 0 1 Rows (1st) Rows (avg) Rows (max) Row Source Operation ---------- ---------- ---------- --------------------------------------------------- 1 1 1 SORT AGGREGATE (cr=2228 pr=2228 pw=0 time=451619 us) 1000000 1000000 1000000 INDEX RANGE SCAN TEST1M_IDX (cr=2228 pr=2228 Event waited on Times Max. Wait Total Waited ---------------------------------------- Waited ---------- ------------ db file sequential read 2228 0.00 0.15 11
  • 12. Scenario #1 – Run (B) call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 1 0.00 0.00 0 0 0 0 Fetch 2 0.07 0.08 0 2228 0 1 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 4 0.08 0.08 0 2228 0 1 Rows (1st) Rows (avg) Rows (max) Row Source Operation ---------- ---------- ---------- --------------------------------------------------- 1 1 1 SORT AGGREGATE (cr=2228 pr=0 pw=0 time=80038 us) 1000000 1000000 1000000 INDEX RANGE SCAN TEST1M_IDX (cr=2228 pr=0 pw=0 12
  • 13. Scenario #1 Solution • Buffer Cache cold/warm • (Part of) the data already in memory • Reduced number of physical reads (pr) • Faster performance because less reads • Number of (same) wait events is lower • Isolated environment likely to read more 13
  • 14. Scenario #2 • SQL – select /*+ FULL(TEST1M) */ count(*) from test1m • Environment – No changes from original setup 14
  • 15. Scenario #2 – Run (A) call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.01 0 0 0 0 Execute 1 0.00 0.00 0 0 0 0 Fetch 2 0.57 1.51 28574 28584 0 1 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 4 0.57 1.52 28574 28584 0 1 Rows (1st) Rows (avg) Rows (max) Row Source Operation ---------- ---------- ---------- --------------------------------------------------- 1 1 1 SORT AGGREGATE (cr=28584 pr=28574 pw=0 time=1513999 us) 1000000 1000000 1000000 TABLE ACCESS FULL TEST1M (cr=28584 pr=28574 Event waited on Times Max. Wait Total Waited ---------------------------------------- Waited ---------- ------------ db file sequential read 1 0.00 0.00 db file scattered read 240 0.02 1.07 15
  • 16. Scenario #2 – Run (B) call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 1 0.00 0.00 0 0 0 0 Fetch 2 1.04 2.42 14286 28583 0 1 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 4 1.04 2.42 14286 28583 0 1 Rows (1st) Rows (avg) Rows (max) Row Source Operation ---------- ---------- ---------- --------------------------------------------------- 1 1 1 SORT AGGREGATE (cr=28583 pr=14286 pw=0 time=2424726 us) 1000000 1000000 1000000 TABLE ACCESS FULL TEST1M (cr=28583 pr=14286 Event waited on Times Max. Wait Total Waited ---------------------------------------- Waited ---------- ------------ db file sequential read 5732 0.01 0.89 db file scattered read 4277 0.00 0.75 16
  • 17. Scenario #2 – Run (A) - Waits WAIT #140245916217600: nam='db file scattered read' ela= 4834 file#=26 block#=16002 blocks=128 WAIT #140245916217600: nam='db file scattered read' ela= 4020 file#=26 block#=16130 blocks=128 WAIT #140245916217600: nam='db file scattered read' ela= 2452 file#=26 block#=16258 blocks=128 WAIT #140245916217600: nam='db file scattered read' ela= 8712 file#=26 block#=16386 blocks=128 WAIT #140245916217600: nam='db file scattered read' ela= 6417 file#=26 block#=16514 blocks=128 WAIT #140245916217600: nam='db file scattered read' ela= 2267 file#=26 block#=16642 blocks=128 WAIT #140245916217600: nam='db file scattered read' ela= 2637 file#=26 block#=16770 blocks=128 WAIT #140245916217600: nam='db file scattered read' ela= 2304 file#=26 block#=16898 blocks=128 WAIT #140245916217600: nam='db file scattered read' ela= 1809 file#=26 block#=17026 blocks=128 WAIT #140245916217600: nam='db file scattered read' ela= 2661 file#=26 block#=17154 blocks=128 17
  • 18. Scenario #2 – Run (B) - Waits WAIT #140245916165224: nam='db file sequential read' ela= 124 file#=26 block#=16002 blocks=1 WAIT #140245916165224: nam='db file scattered read' ela= 139 file#=26 block#=16004 blocks=2 WAIT #140245916165224: nam='db file sequential read' ela= 117 file#=26 block#=16007 blocks=1 ….<<another 38 waits here>> WAIT #140245916165224: nam='db file sequential read' ela= 132 file#=26 block#=16113 blocks=1 WAIT #140245916165224: nam='db file sequential read' ela= 123 file#=26 block#=16116 blocks=1 WAIT #140245916165224: nam='db file scattered read' ela= 142 file#=26 block#=16118 blocks=2 WAIT #140245916165224: nam='db file scattered read' ela= 141 file#=26 block#=16121 blocks=2 WAIT #140245916165224: nam='db file scattered read' ela= 135 file#=26 block#=16124 blocks=2 WAIT #140245916165224: nam='db file sequential read' ela= 119 file#=26 block#=16127 blocks=1 18
  • 19. Scenario #2 Solution • Buffer cache status (cold/warm) • (Part of) the data already in memory • Reduced number of physical reads (pr) • Number of (same) wait events is higher • Wait events details help track it down – Non-contiguous blocks read • Slower performance because smaller reads 19
  • 21. Scenario #3 – Run (A) call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 1 0.00 0.00 0 0 0 0 Fetch 2 0.92 2.96 14286 28583 0 1 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 4 0.92 2.96 14286 28583 0 1 Rows (1st) Rows (avg) Rows (max) Row Source Operation ---------- ---------- ---------- --------------------------------------------------- 1 1 1 SORT AGGREGATE (cr=28583 pr=14286 pw=0 time=2967930 us) 1000000 1000000 1000000 TABLE ACCESS FULL TEST1M (cr=28583 pr=14286 Event waited on Times Max. Wait Total Waited ---------------------------------------- Waited ---------- ------------ db file sequential read 5732 0.10 1.17 db file scattered read 4277 0.28 1.13 21
  • 22. Scenario #3 – Run (B) call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 1 0.00 0.00 0 0 0 0 Fetch 2 0.11 1.01 28573 28575 0 1 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 4 0.11 1.02 28573 28575 0 1 Rows (1st) Rows (avg) Rows (max) Row Source Operation ---------- ---------- ---------- --------------------------------------------------- 1 1 1 SORT AGGREGATE (cr=28575 pr=28573 pw=0 time=1019952 us) 1000000 1000000 1000000 TABLE ACCESS FULL TEST1M (cr=28575 pr=28573 Event waited on Times Max. Wait Total Waited ---------------------------------------- Waited ---------- ------------ enq: KO - fast object checkpoint 2 0.00 0.00 direct path read 179 0.03 0.90 22
  • 23. Scenario #3 – Solution • Buffered vs Direct Path reads (different waits too) • (Part of) the data already in memory • Direct Path – skips Buffer Cache and reads whole table every time – consistent performance – number of wait events is consistent • Buffered vs Direct Path decision is made AFTER plan selection (several criteria) 23
  • 25. Scenario #4 – Run (A) call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.01 0 0 0 0 Execute 1 0.00 0.00 0 0 0 0 Fetch 2 0.57 3.08 15872 15884 1 1 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 4 0.57 3.10 15872 15884 1 1 Rows (1st) Rows (avg) Rows (max) Row Source Operation ---------- ---------- ---------- --------------------------------------------------- 1 1 1 SORT AGGREGATE (cr=15884 pr=15872 pw=0 time=3086869 us) 1000000 1000000 1000000 TABLE ACCESS FULL TEST1M (cr=15884 pr=15872 Event waited on Times Max. Wait Total Waited ---------------------------------------- Waited ---------- ------------ db file scattered read 2005 0.05 2.53 25
  • 26. Scenario #4 – Run (B) call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 1 0.00 0.00 0 0 0 0 Fetch 2 0.32 1.66 15872 15881 0 1 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 4 0.32 1.66 15872 15881 0 1 Rows (1st) Rows (avg) Rows (max) Row Source Operation ---------- ---------- ---------- --------------------------------------------------- 1 1 1 SORT AGGREGATE (cr=15881 pr=15872 pw=0 time=1660864 us) 1000000 1000000 1000000 TABLE ACCESS FULL TEST1M (cr=15881 pr=15872 Event waited on Times Max. Wait Total Waited ---------------------------------------- Waited ---------- ------------ db file scattered read 141 0.05 1.41 26
  • 27. Scenario #4 – Run (A) - Waits WAIT #139702845969088: nam='db file scattered read' ela= 265 file#=25 block#=306 blocks=8 WAIT #139702845969088: nam='db file scattered read' ela= 257 file#=25 block#=314 blocks=8 WAIT #139702845969088: nam='db file scattered read' ela= 259 file#=25 block#=322 blocks=8 WAIT #139702845969088: nam='db file scattered read' ela= 254 file#=25 block#=330 blocks=8 ….. WAIT #139702845969088: nam='db file scattered read' ela= 217 file#=25 block#=378 blocks=6 WAIT #139702845969088: nam='db file scattered read' ela= 270 file#=25 block#=386 blocks=8 WAIT #139702845969088: nam='db file scattered read' ela= 283 file#=25 block#=394 blocks=8 WAIT #139702845969088: nam='db file scattered read' ela= 263 file#=25 block#=402 blocks=8 27
  • 28. Scenario #4 – Run (B) - Waits WAIT #139702846026760: nam='db file scattered read' ela= 13508 file#=25 block#=258 blocks=128 WAIT #139702846026760: nam='db file scattered read' ela= 9016 file#=25 block#=386 blocks=128 28
  • 29. Scenario #4 – Solution 1 • Different db_file_multiblock_read_count value • Same number of blocks read from disk • Number of (same) wait events is higher • Wait events details help track it down – Contiguous blocks read • Slower performance because smaller reads 29
  • 30. Scenario #4 – Solution 2 • Different extent size (64k vs 1M) • Same number of blocks read from disk • Number of (same) wait events is higher • Wait events details help track it down – Contiguous blocks read • Same params/stats but different storage org • Slower performance because smaller reads 30
  • 31. Scenario #5 • SQL – select /*+ FULL(TEST1M) */ count(*) from test1m • Env changes – No changes – BC cold, MBRC and extent are identical 31
  • 32. Scenario #5 – Run (A) call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 1 0.00 0.00 0 0 0 0 Fetch 2 0.26 0.72 14285 14297 1 1 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 4 0.27 0.72 14285 14297 1 1 Rows (1st) Rows (avg) Rows (max) Row Source Operation ---------- ---------- ---------- --------------------------------------------------- 1 1 1 SORT AGGREGATE (cr=14297 pr=14285 pw=0 time=723883 us) 1000000 1000000 1000000 TABLE ACCESS FULL TEST1M (cr=14297 pr=14285 Event waited on Times Max. Wait Total Waited ---------------------------------------- Waited ---------- ------------ db file scattered read 128 0.04 0.51 32
  • 33. Scenario #5 – Run (B) call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 1 0.00 0.00 0 0 0 0 Fetch 2 0.44 1.29 28574 28586 1 1 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 4 0.44 1.29 28574 28586 1 1 Rows (1st) Rows (avg) Rows (max) Row Source Operation ---------- ---------- ---------- --------------------------------------------------- 1 1 1 SORT AGGREGATE (cr=28586 pr=28574 pw=0 time=1291333 us) 1000000 1000000 1000000 TABLE ACCESS FULL TEST1M (cr=28586 pr=28574 Event waited on Times Max. Wait Total Waited ---------------------------------------- Waited ---------- ------------ db file scattered read 240 0.04 0.95 33
  • 34. Scenario #5 – Solution 1 • Different PCTFREE (0 vs 50) • Higher number of blocks read for same data • Reads are of the same size hence more reads • Data is more spread out, room for changes • Slower performance because more reads 34
  • 35. Scenario #5 – Solution 2 • Empty blocks below HWM • Higher number of blocks read for same data • Reads are of the same size hence more reads • Data has been deleted, FTS reads everything • Slower performance because more reads 35
  • 36. Scenario #6 • SQL – select /*+ FULL(TEST1M) */ count(*) from test1m • Env changes – No changes – BC cold, MBRC, PCTFREE and extent are identical 36
  • 37. Scenario #6 – Run (A) call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 1 0.00 0.00 0 0 0 0 Fetch 2 0.44 1.29 28574 28586 1 1 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 4 0.44 1.29 28574 28586 1 1 Rows (1st) Rows (avg) Rows (max) Row Source Operation ---------- ---------- ---------- --------------------------------------------------- 1 1 1 SORT AGGREGATE (cr=28586 pr=28574 pw=0 time=1291333 us) 1000000 1000000 1000000 TABLE ACCESS FULL TEST1M (cr=28586 pr=28574 Event waited on Times Max. Wait Total Waited ---------------------------------------- Waited ---------- ------------ db file scattered read 240 0.04 0.95 37
  • 38. Scenario #6 – Run (B) call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 1 0.00 0.00 0 0 0 0 Fetch 2 0.73 2.49 28803 58584 0 1 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 4 0.74 2.49 28803 58584 0 1 Rows (1st) Rows (avg) Rows (max) Row Source Operation ---------- ---------- ---------- --------------------------------------------------- 1 1 1 SORT AGGREGATE (cr=58584 pr=28803 pw=0 time=2492596 us) 1000000 1000000 1000000 TABLE ACCESS FULL TEST1M (cr=58584 pr=28803 Event waited on Times Max. Wait Total Waited ---------------------------------------- Waited ---------- ------------ db file scattered read 240 0.23 1.73 cell single block physical read 230 0.01 0.06 38
  • 39. Scenario #6 – Waits and SesStats • Wait events show – single block reads from UNDO tbs for obj#=0 WAIT #140029131327704: nam='db file scattered read' ela= 15412 file#=26 block#=15618 blocks=128 obj#=74828 WAIT #140029131327704: nam='cell single block physical read' ela= 220 … bytes=8192 obj#=0 WAIT #140029131327704: nam='db file scattered read' ela= 11786 file#=26 block#=15746 blocks=128 obj#=74828 WAIT #140029131327704: nam='cell single block physical read' ela= 233 … bytes=8192 obj#=0 WAIT #140029131327704: nam='db file scattered read' ela= 5938 file#=26 block#=15874 blocks=128 obj#=74828 WAIT #140029131327704: nam='cell single block physical read' ela= 224 … bytes=8192 obj#=0 WAIT #140029131327704: nam='db file scattered read' ela= 12162 file#=26 block#=16002 blocks=128 obj#=74828 • v$sesstat shows high – data blocks consistent reads - undo records applied 39
  • 40. Scenario #6 - Solution • Different concurrency/workload • Higher number of blocks read for same data • Waits -> reads from UNDO tbs • SesStats -> UNDO records applied • Slower performance because more reads + more work to recreate the correct image 40
  • 41. Scenario #7 • SQL – select /* 1st run */ n1,c1 from test1m where n1 in (1,1000,5000) • Env changes – Index on TEST1M(N1) – BC cold, MBRC, PCTFREE and extent are identical – No concurrency at the time SQL is executed 41
  • 42. Scenario #7 – Why so many cr/pr? call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 1 0.00 0.00 0 0 0 0 Fetch 2 0.00 0.75 11 18 0 3 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 4 0.00 0.75 11 18 0 3 Rows (1st) Rows (avg) Rows (max) Row Source Operation ---------- ---------- ---------- --------------------------------------------------- 3 3 3 INLIST ITERATOR (cr=18 pr=11 pw=0 time=235681 us) 3 3 3 TABLE ACCESS BY INDEX ROWID TEST1M (cr=18 pr=11 3 3 3 INDEX RANGE SCAN TEST1M_IDX (cr=9 pr=5 pw=0 Event waited on Times Max. Wait Total Waited ---------------------------------------- Waited ---------- ------------ db file sequential read 11 0.18 0.52 42
  • 43. Scenario #7 – Waits and SesStats • Wait events show – single block reads from data tbs, same obj# WAIT #140…: nam='db file sequential read' ela= 7414 file#=26 block#=2356 blocks=1 obj#=75022 WAIT #140…: nam='db file sequential read' ela= 41395 file#=26 block#=131 blocks=1 obj#=74828 WAIT #140…: nam='db file sequential read' ela= 181594 file#=26 block#=78403 blocks=1 obj#=74828 • v$sesstat shows high – table fetch continued row 43
  • 44. Scenario #7 - Solution • Row migration, index points to original rowid • Higher number of blocks read for same data • Waits -> reads are from data tbs • SesStats -> table fetch continued row • Slower performance because more reads + more work to find all the row pieces • Similar behavior happens with chained rows 44
  • 45. Scenario #8 • SQL – select /* 2nd run */ n1,c1, ora_rowscn from test1m where rownum <= 5000 • Env changes – Index on TEST1M(N1) – BC cold, MBRC, PCTFREE and extent are identical – No concurrency at the time SQL is executed 45
  • 46. Scenario #8 - Why so many seq read? call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 1 0.00 0.00 0 0 0 0 Fetch 6 0.03 0.22 393 5378 0 5000 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 8 0.03 0.22 393 5378 0 5000 Rows (1st) Rows (avg) Rows (max) Row Source Operation ---------- ---------- ---------- ------------------------------------------- 5000 5000 5000 COUNT STOPKEY (cr=5378 pr=393 pw=0 time=91193 5000 5000 5000 TABLE ACCESS FULL TEST1M (cr=5378 pr=393 Event waited on Times Max. Wait Total Waited ---------------------------------------- Waited ---------- ------------ db file sequential read 381 0.00 0.19 db file scattered read 2 0.00 0.00 46
  • 47. Scenario #8 – Waits and SesStats • Wait events show – single block reads from data tbs, same obj# WAIT #1405…: nam='db file scattered read' ela= 6434 file#=26 block#=132 blocks=4 obj#=74828 WAIT #1405…: nam='db file sequential read' ela= 193 file#=26 block#=78670 blocks=1 obj#=74828 WAIT #1405…: nam='db file sequential read' ela= 182 file#=26 block#=78686 blocks=1 obj#=74828 WAIT #1405…: nam='db file sequential read' ela= 3445 file#=26 block#=7890 blocks=1 obj#=74828 • v$sesstat shows high – table fetch continued row 47
  • 48. Scenario #8 - Solution • Row migration, pseudo col needs row header • Higher number of blocks read for same data • Waits -> reads are from data tbs • SesStats -> table fetch continued row • Slower performance because more reads + more work to find all the row pieces • Similar behavior happens with chained rows 48
  • 49. Other things to consider • Same PHV with small differences – Predicate ordering – Column projection • Exadata Optimizations – Exadata Smart Flash Cache – Storage indexes • External to the database – File system / SAN / Disk caching – Read-ahead optimizations 49
  • 50. Conclusions • Same plan can still run differently • Storage organization and concurrency impact • Fix one scenario can introduce another, ie. – low PCTFREE higher chance of row migration – high caching slows down buffered mreads • Find a balance to achieve optimal performance 50
  • 51. 51
  • 52. References • 'DB_FILE_MULTIBLOCK_READ_COUNT' AND EXTENTS MANAGEMENT (Doc ID 181272.1) • Higher 'direct path read' Waits in 11g when Compared to 10g (Doc ID 793845.1) • Why Is My Query Sometimes Slower Than Other Times with Higher Consistent Gets Although No Change in Execution Plan? (Doc ID 1558349.1) • Row Chaining and Row Migration (Doc ID 122020.1) 52
  • 53. Contact Information • http://mauro-pagano.com – Email • mauro.pagano@gmail.com – Download • SQLd360 vYYMM (date) – Pages • SQLd360 53