System Statistics Are A Little Complex: Neil Chandler's DB Blog
System Statistics Are A Little Complex: Neil Chandler's DB Blog
Advertisements
REPORT THIS AD
[tl;dr – in almost all cases, DON’T GATHER SYSTEM STATISTICS. DON’T SET MBRC. LET
THEM DEFAULT!]
First you need to be armed with a piece of information. When Oracle optimizes your SQL, it
produces a COST to compare each SQL execution plan. Exactly what is this COST? It’s not
seconds. It’s not quite the amount of I/O required. It’s not an arbitrary figure either. Oracle
Optimizer Cost is the cost of getting your data in terms of SINGLE BLOCK READS. Remember this
for later.
Lets have a look at the system stats defaults :
REPORT THIS AD
What we are looking for here is the the 3 metrics highlighted in colour. As we can see, the are not
set. By default, we need to calculate those, or know where to find the defaults for those values to
get to them. Once we have those 3 metrics, we can calculate the RATIO used by the optimizer to
convert MULTIBLOCK READ into a cost metric of SINGLE BLOCK READS.
The CPU speed is used to calculate the COST of the query in terms of CPU required. This is small
percentage of the query cost but it may help decide which plan is chosen. This is also converted
from CPU cost into a cost metric of SINGLE BLOCK READS.
much 270,833
We can also work out the CPU element of the COST.
Scan IO Cost (Disk) = 270835.000000
Cost: 271041.492812
so CPU cost must be 271041.492812 – 270835.000000 = 206.492812
Scan CPU Cost (Disk)=7411440000.000001 so doing the maths to convert to units of “single
block read time”…
You want to play yourself and see what happens? Of course you do…
Here’s an excel spreadsheet where you can plug in your numbers and see what happens to the
ratio between single and multi block reads to see how system stats influence the optimizer. By
plugging in different numbers, you will see how complex the interactions are – so what’s the
ideal numbers? Use the DEFAULTS in almost all cases** [WARNING – don’t go changing your
system stats based on this statement. You might experience a significant amount of plan
changes, some of which may be very very bad!]:
[warning – I wrote this is a few mins and it’s not very tested] system_statistics.xlsDownload
Also, this is my version of a script by Franck Pachot, and also based on work by Chris Antognini,
which you can run against your system:
Here’s a mild frustration from this week that I encountered. I was installing Goldengate…
Checking Temp space: must be greater than 120 MB. Actual 21571 MB Passed
Checking swap space: must be greater than 150 MB. Actual 24575 MB Passed
I’d better re-read this error message carefully… Unexpected error occurred while validating
inputs at state ‘installOptions’. What? Validating inputs? Lets have a look at the inputs from the
response file:
install_source.rsp
###########################################################################
#####
## ##
## ##
###########################################################################
#####
#--------------------------------------------------------------------------
-----
# Specify ORA19c for installing Oracle GoldenGate for Oracle Database 19c
or
#--------------------------------------------------------------------------
-----
INSTALL_OPTION=ORA11G
#--------------------------------------------------------------------------
-----
#--------------------------------------------------------------------------
-----
SOFTWARE_LOCATION=/u01/gg
START_MANAGER=
MANAGER_PORT=
DATABASE_LOCATION=
INVENTORY_LOCATION=
UNIX_GROUP_NAME=
I only have 2 inputs; the INSTALL_OPTION and the SOFTWARE_LOCATION… and the
INSTALL_OPTION is wrong! This field is case sensitive. ORA11G does not match ORA11g, so I get
a dramatic null pointer exception and a failure. It would have been a much quicker remediation
if the Oracle error had been curated a little better and the programmer a little more sympathetic
to users of their code.
How about:
Installation parameter INSTALL_OPTION invalid,
rather than
Unexpected error occurred while validating inputs at state ‘installOptions’
Lets see what happened and what I had to do to actually get a database link with the same name
as the database.
> create database link ORA11A connect to neil identified by neil using
'ORA11A';
(restart db)
> create database link ORA11A connect to neil identified by neil using
'ORA11A';
GLOBAL_NAME
------------------------------
ORA19A.CHANDLER.UK.COM
So maybe it’s taking the domain from here? Can I prove that?
Database altered.
GLOBAL_NAME
------------------------------
ORA19A.COM
> create database link ORA11A connect to neil identified by neil using
'ORA11A';
[note that I had not deleted the previous DB link so it was still there!]
Database altered.
GLOBAL_NAME
------------------------------
ORA19A.COM
Oh dear. You can’t remove a domain suffix from a global name. If you don’t specify the
domain, Oracle helpfully adds it right back in there for you.
You need to correct this in an unorthodox way.
The GLOBAL_NAME is really a value in SYS.PROPS$
TEXT
-----------------------------------------------------------
VALUE$ COMMENT$
------------------------------ --------------------------------------------
------------------------------------
1 row updated.
> commit;
Commit complete.
VALUE$ COMMENT$
------------------------------ --------------------------------------------
------------------------------------
> create database link ORA11A connect to neil identified by neil using
'ORA11A';
Database link created.
If only I’d created the database without specifying a db_domain in the first place…
UKOUG Techfest19
I’ve just returned from Techfest19 – the UKOUG Flagship Oracle Tech conference – and it was
simply excellent.
It was held at The Grand Hotel in Brighton, and it was grand. If you missed it, you really missed
out. 250 mostly amazing presentations.
I did 2 main ones about Oracle Statistics, and also MC’d the Jonathan Lewis Optimizer Panel,
alongside Martin Widlake. The highlight of my conference was asking a left-field question of an
Oracle Architect about Full Table Scans, which has resulted in the potential for a change to the
code to make them (possibly slightly) more efficient. Thank you for listening Roger!
If you missed my 2 sessions on Database Statistics, you can find a webinar and a Blair-Witch
style video of each of them here on my website:
The first, starting Tuesday 18th November, is DOAG – the German Oracle User Group – in Nuremberg.
I’ll be talking about Oracle Database Statistics, but this time in 2 slots, Database Stats #1. Doing
it Right, the Easy Way (Monday 2nd December 09:00), then in a bit more depth I’ll do Database
Stats #2. Doing it Right, When it’s Harder (Wednesday 4th December 11:00)
For a UKOUG “conference survival guide”, I recommend
UKOUG Techfest
Survival Guide 2019. All you need to know about getting the most out of 3.5 days of Tech shenanigans.
Turn up, learn, but also try to meet people and have fun! I hope to see you at one of both of these
conferences, maybe have a coffee or somethings stronger – easy on the stalking though (read Martins
Survival Guide first)
If you have not registered for Techfest 2019, you can do that here: UKOUG TechFest 2019!
There a full agenda of around 250 Oracle-related Tech talks. The problem isn’t trying to work
out if there’s enough to see, but trying to work out how to prioritise all of them!
See you there!
Older posts
Categories
Categories Select
Category ACFS Administration Appearances audit Backups DataGuard Datapump Development doag Goldengate
GRID Infrastructure HrOUG Ireland Management Migration oracle patching Performance and
Tuning POUG Prevarication Problem
Solving Programming RAC Recruitment rigadevdays RMAN SAN SCHEMA Security sig SIOUG spm SpOUG SQL
UKOUG Uncategorized Unix User Groups
Archives
Archives Select Month February 2021 July 2020 December 2019 November 2019 September 2019 March
2019 February 2019 January 2019 November 2018 October 2018 September 2018 August 2018 June
2018 May 2018 April 2018 March 2018 February 2018 January 2018 December 2017 November
2017 September 2017 August 2017 May 2017 March 2017 February 2017 January 2017 December
2016 November 2016 October 2016 September 2016 July 2016 May 2016 April 2016 March
2016 February 2016 January 2016 November 2015 October 2015 September 2015 August 2015 July
2015 June 2015 May 2015 April 2015 March 2015 February 2015 January 2015 December
2014 November 2014 October 2014 September 2014 June 2014 May 2014 April 2014 March
2014 December 2013 November 2013 October 2013 September 2013 August 2013 July 2013 May
2013 February 2013 January 2013 September 2012 August 2012 July 2012 June 2012 May 2012 April
2012 March 2012 February 2012 January 2012 December 2011 November 2011 October 2011 September
2011 July 2011 May 2011 March 2011
MyWebsite
• Neil Chandler
My Tweets
Meta
• Register
• Log in
• Entries feed
• Comments feed
• WordPress.com