Professional Documents
Culture Documents
Copyright 2015. LoadSpring is a trademark of LoadSpring Solutions, Inc. All Rights Reserved. loadspring.com Follow us on:
JULY/AUGUST 2015
Push a Button
Move Your Database
to the Oracle Cloud
Same Database
Same Standards
Same Architecture
cloud.oracle.com/database
or call 1.800.ORACLE.1
Copyright 2015, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates.
CONTENTS
Integrate and extend your cloud with more than two dozen new PaaS services.
THE CLOUD MADE WHOLE
Oracle completes its cloud
platform. /20
SAME CODE, SAME
STANDARDS, SAME
ARCHITECTURE
Technical deep dives demonstrate
proven cloud technology. /24
Up Front / 5
Community / 14
Technology / 31
PARTNER NEWS / 14
BOOK BEAT / 14
COMMUNITY
BULLETIN / 16
ORACLE MOBILE
APPLICATION
FRAMEWORK / 31
Big
MASHUP / 6
News, views, trends,
and tools
At Oracle / 8
EVENTS / 8
Find out about upcoming
technology and industry
events.
RESOURCES / 9
Your guide to the latest
Oracle videos, webcasts,
white papers, and more
BRIEFS / 10
The latest product news
INTERVIEW / 13
Cloud Foundation
Standards
Happenings in Oracle
Technology Network
Roland Smart
ARCHITECT / 17
Taming Change
PEER-TO-PEER / 19
Improv 101
ASK TOM / 49
On Learning from
Mistakes
Our technologist
demonstrates how the Oracle
Database optimizer learns
and how to help it.
Tom Kyte
PL/SQL / 37
On Cursors, Context,
Switches, and Mistakes
There are good ways, and
other ways, to get data from
tables. Steven Feuerstein
DBA / 43
Comment / 56
IN THE FIELD / 56
History, Hyper-Growth,
and the Hunt
The president of ODTUG
looks back, looks at growth,
and looks at Kscope.
Tom Haunert
Beginning Performance
Tuning: Trace Your Steps
Trace sessions to document
activity details and identify
bottlenecks. Arup Nanda
EDITORIAL
Editor in ChiefTom Haunerttom.haunert@oracle.com
Managing EditorJan Rogersjan.rogers@oracle.com
Associate Editor Patty Waddington
Contributing Editor and Writer Blair Campbell
Technology Advisor Tom Kyte
Contributor Leslie Steere
Editorial Director Robert Preston
DESIGN
Senior Creative Director Francisco G Delgadillo
Design Director Richard Merchn
Senior Designer Arianna Pucherelli
Designer Jaime Ferrand
Senior Production Manager Sheila Brennan
Production Designer Kathy Cygnarowicz
PUBLISHING
PublisherJennifer Hamiltonjennifer.hamilton@oracle.com+1.650.506.3794
Associate Publisher and Audience Development DirectorKarin Kinnearkarin.kinnear@oracle.com+1.650.506.1985
Audience Development ManagerJennifer Kurtzjennifer.s.kurtz@oracle.com
Advertising Production Director Joy Jacob
ADVERTISING SALES
President, Sprocket MediaKyle Walkenhorstkyle@sprocketmedia.com+1.323.340.8585
Western and Central US, LAD, and Canada, Sprocket MediaTom Cometatom.cometa@oracle.com+1.510.339.2403
Eastern US and EMEA/APAC, Sprocket MediaMark Makinneymark.makinney@sprocketmedia.com+1.805.709.4745
Recruitment Advertising, Sprocket MediaJosie Damianjosie.damian@sprocketmedia.com+1.626.396.9400, x200
Advertising Sales Assistant, Sprocket MediaCindy Elhajcindy@sprocketmedia.com+1.626.396.9400, x201
Mailing-List Rentals Contact your sales representative.
EDITORIAL BOARD
Ian Abramson, Karen Cannell, Andrew Clarke, Chris Claterbos, Karthika Devi, Kimberly Floss, Kent Graziano, Taqi Hasan,
Tony Jambu, Tony Jedlinski, Ari Kaplan, Val Kavi, John King, Steve Lemme, Carol McGury, Sumit Sengupta,
Jonathan Vincenzo, Dan Vlamis
SUBSCRIPTION INFORMATION
Subscriptions are complimentary for qualified individuals who complete the form found at
oracle.com/oraclemagazine. For change of address, mail in label with the new address to:
Oracle Magazine, P.O. Box 1263, Skokie, IL 60076-8263.
MAGAZINE CUSTOMER SERVICE
oracle@halldata.com Fax +1.847.763.9638 Phone +1.847.763.9635
RESOURCES
Oracle Products
+1.800.367.8674 (US/Canada)
Oracle Services
+1.888.283.0591
Oracle Press Books
oraclepressbooks.com
PRIVACY
Oracle Publishing allows sharing of its mailing list with selected third parties. If you prefer that your
mailing address or e-mail address not be included in this program, contact Customer Service at
oracle@halldata.com.
Copyright 2015, Oracle and/or its affiliates. All Rights Reserved. No part of this publication may be reprinted or otherwise reproduced without permission from the editors. ORACLE MAGAZINE IS PROVIDED ON
AN AS IS BASIS. ORACLE EXPRESSLY DISCLAIMS ALL WARRANTIES, WHETHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ORACLE BE LIABLE FOR ANY DAMAGES OF ANY KIND ARISING FROM YOUR
USE OF OR RELIANCE ON ANY INFORMATION PROVIDED HEREIN. The information is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into
any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality
described for Oracles products remains at the sole discretion of Oracle. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
Oracle Magazine (ISSN 1065-3171) is published bimonthly with a free subscription price by: Oracle, 500 Oracle Parkway, MS OPL-3A, Redwood City, CA 94065-1600. Periodicals Postage Paid at Redwood City,
CA, and additional mailing offices. POSTMASTER: Send address changes to: Oracle Magazine, P.O. Box 1263, Skokie, IL 60076-8263.
Big
NEXT STEPS
READ more about Oracle Cloud Platform
bit.ly/oraclecloudplatform
WATCH the Oracle Cloud Platform
launch event
oracle.com/us/corporate/events/cloud-platform
REGISTER for Oracle OpenWorld 2015,
San Francisco
oracle.com/openworld
CONNECT:
bit.ly/orclmagcom
bit.ly/orclmagfb
linkd.in/orclmag
ORACLE MAGAZINE JULY/AUGUST 2015
MashUp
Math Ref
Featuring an
expanding inventory
of tools for common
tasks, Math Ref
provides formulas
and equations to go.
Browse more than
1,400 figures and
examples to help you
with math, physics,
and chemistry.
US$0.99 Android,
US$1.99 iOS.
happymaau.com/
projects/math-ref
Memrise
Offering courses
created by its community in everything
from history to
memory training,
Memrises clever
technology adapts
to your personal
learning style. Create
your own courses
with rich multimedia
flash cards. Free
(Android, iOS).
memrise.com
Spotzi-Atlas
Based on data
from agencies
such as NASA and
the World Bank,
Spotzi shows you
maps of the world
in unique detail,
enriched with video
and online articles.
Browse for themes
such as animals,
temperatures, and
tectonic plates.
Free (Android, iOS,
Windows).
spotzi.com
Web2go
Listen to news
websites, online
magazines, RSS
feeds, and blogsall
read aloud. Web2go
lets you select
articles and updates
from more than
1,000 websites
to create custom
article playlists you
can listen to on the
go. Free (Android,
Windows).
volacent.com
QUIZ YOURSELF!
1. STEAM stands for _________ .
BATTERY
EXTROVERT
Tired of backup batteries that are too big to
carry everywhere? Stay charged and connected with the bKey cable-free emergency
external smartphone battery. bKey has a
built-in USB tip and a micro-USB or iPhone
tip to charge your iOS or Android phone on
the go. bKey is no bigger than a car key but
delivers a 350 milliampere-hour lithium-ion
battery good for up to 45 minutes of battery
life. Attach it to your key ring for use whenever you need it. US$29.99. shopbkey.com/
products/bkey
Answers
Tech in the
Classroom
Teachers in the US
Smart Padlock
Eliminate the hassle of keys
and combinations with Noke
from FU-Z Designs. Use Noke
with your iOS or Android
smartphone for easy access
to your possessions, and share
them safely and securely.
Choose permanent, one-time,
or custom settings. Use Noke
wherever you would normally
use an ordinary padlock. Also
available in a U-lock configuration. US$69.99. fuzdesigns
.com/products/Noke
Business-wise, Future-driven.
EVENTS
Technology Events
Rise
bit.ly/1Hazsnf
bit.ly/1D9k3gk
bit.ly/1Gcg7Pl
bit.ly/1aM3W0r
InterDrone
GROW
EVENTS LOCATOR
Oracle Events
oracle.com/events
Locate User Groups
oracle.com/technetwork/community
bit.ly/1DvqNoc
nocoug.org
bit.ly/1O97lcb
nwoug.org
neooug.org/events
bit.ly/1G1DuZr
nyoug.org/events
ncoaug.com
September 28October 1,
San Francisco, California
fbit.ly/1cSAS9k
BrainStorm offers intensive full-day training and
workshops covering the real-world skills needed
to successfully implement continuous process
improvement in any organization.
jdescug.org
bit.ly/1D9l9ZE
GETTY IMAGES
RESOURCES
WEBCASTS
VIDEOS
RESOURCE CENTERS
E-BOOKS
Establishing a Mobile Security Architecture
fbit.ly/1v31J9r
Written for mobility planners, security architects,
chief information security officers, security directors, IT directors, and operations managers, this
e-book will help you understand the best application of technologies for each area of mobility
within your organization.
Modern HR for Dummies
fbit.ly/1ODmX2A
Learn to create a talent-centric business
strategy, build a collaborative workplace culture,
and deliver engaging HR applications.
CONNECT:
oracle.com/blogs
facebook.com/oracle
linkedin.com/company/oracle
INFOGRAPHICS
Oracle Engineered Systems: A Smart Choice
fbit.ly/1Eumw99
Learn why integrated IT systems are the smart
choice for forward-thinking IT professionals.
Unlock Your Full Sales Potential
fbit.ly/1PdkyOi
Learn how using business intelligence and predictive analytics software can help organizations
make gains in productivity, satisfaction, and
sales volume.
WEB LOCATOR
Oracle Consulting
oracle.com/consulting
Oracle Events and Webcasts
oracle.com/events
Oracle Newsletters
oracle.com/newsletters
Oracle Podcast Center
oracle.com/podcasts
Oracle Support
oracle.com/support
Oracle Training and Certification
bit.ly/ouoramag
My Oracle Support
myoraclesupport.com
My Oracle Support Communities
communities.oracle.com
bit.ly/plusOracle
ORACLE MAGAZINE JULY/AUGUST 2015
Press Headlines
Oracle Helps Marketers Leverage
Data Trapped in Different
Marketing Systems
fbit.ly/1Cl9zsK
fbit.ly/1E6bnqr
fbit.ly/1K6FXbV
fbit.ly/1EhfsM2
fbit.ly/1PH3DBV
I-HUA CHEN
10
BRIEFS
I-HUA CHEN
11
OCA Java SE 8
Programmer I Study Guide
(Exam 1Z0-808)
Edward Finegan, Rob Liguori
Get complete coverage of all objectives
for Exam 1Z0-808. Electronic practice
exam questions are included.
Oracle SOA Suite 12c Handbook
Lucas Jellema
Implement an agile, service-oriented
enterprise computing infrastructure.
Available September
NEXT STEPS
LEARN more about
Oracle Linux
oracle.com/us/technologies/linux
Oracles Virtual Compute Appliance
oracle.com/servers/virtual-compute-appliance
13
14
Book Beat
Understanding Oracle APEX 5
Application Development
By Edward Sciore
Apress
apress.com
Understanding Oracle
APEX 5 Application
Development introduces
new users of the product
to its properties and functionality, and
suggests development techniques for
creating polished web applications. Topics
covered include conditional formatting,
user-customized reports, data entry forms,
concurrency and lost updates, and updatable reports.
PARTNER NEWS
I-HUA CHEN
15
16
Community Bulletin
BY ROLAND
SMART
News, People,
Happenings
in and
Oracle
Happenings
Technology
in the
Network
Oracle Technology
Network
Technologists: Start
Your Nominations
Connect
with Oracle
Engineers:
Visit My Oracle
Support Blogs
Powered by community
.oracle.com, My Oracle
Support Blogs allow you
to hear directly from
Oracle Support engineers. Discover their
latest insights on a wide
range of Oracle products,
platforms, and technologies, including Oracle
Enterprise Manager 12c,
Oracle WebCenter, and
Oracle Taleo Enterprise
Cloud Service. And keep
track of the most-recent
product releases, documentation, and service
announcements with the
Support Blogs portal.
Subscribe to regular
e-mail notifications
or receive a weekly or
twice-weekly digest of
the blog contributions
relevant to your area of
technical expertise.
Find the My Oracle
Support Blogs at bit.ly/
mosc-support-blogs.
FEATURED DOWNLOAD:
Oracle SQL
Developer 4.1
I-HUA CHEN
JA15_Community_R1.indd 16
7/27/15 3:32 PM
Taming Change
blogs.oracle.com/archbeat
Every new
technology requires
a considerable
amount of time.
Antonis Antoniou, Oracle ACE Associate
facebook.com/brhubart
twitter.com/brhubart
Bob Rhubart
(bob.rhubart@oracle.com)
is manager of the
architect community
on Oracle Technology
Network, the host of the
Oracle Technology Network ArchBeat podcast
series, and the author of the ArchBeat blog.
NEXT STEPS
LISTEN to these ArchBeat podcast series
Microservices Roundtable
bit.ly/1DydXFj
Docker and Virtualization
bit.ly/1HOBXu1
The Case for Adaptive Case Management
bit.ly/1EEnfUH
Oracle Data Integrator and the Evolution of
Data Integration
bit.ly/1uAuzvd
linkedin.com/in/bobrhubart
ORACLE MAGAZINE JULY/AUGUST 2015
17
Convert to Digital!
Improv 101
Three peers on brainstorming without judging, failing, and swapping techno for tech
EDELWEISS KAMMERMANN
KEVIN MCGINLEY
KLAAS-JAN JONGSMA
19
21
BY JOHN SOAT
THE CLOUD
MADE WHOLE
Oracle completes its cloud platform.
I-HUA CHEN
22
CHARLOTTE FIORITO/COMPASSPHOTOGRAPHERS.COM
23
NEXT STEPS
LEARN more about
Oracle Cloud Platform
oracle.com/cloud/paas.html
bit.ly/paascomp
Oracle Database Cloud Exadata Service
oracle.com/us/corporate/features/exadata-service
WATCH the Oracle Cloud Platform 2015 launch event
videos on demand
oracle.com/us/corporate/events/cloud-platform
Same Code,
Same Standards,
Same Architecture
F
CHARLOTTE FIORITO/COMPASSPHOTOGRAPHERS.COM
24
www.polarbearsinternational.org
25
Left to right: Steve Daheb, Senior Vice President of Oracles PaaS, Business Intelligence, and Enterprise Performance Management Business Groups; Fari Ebrahimi,
Senior Vice President and Global Chief Information Officer, Avaya; Rajeev Sethi, Senior Director of IT Applications, JDS Uniphase; Michael Kuban, Director of
Enterprise Solutions Delivery, Pharmavite; Mark Willford, Senior Managing Director, Accenture
CHARLOTTE FIORITO/COMPASSPHOTOGRAPHERS.COM
26
27
types of business-to-consumer
retail promotions every night,
companies in the United States
and then makes the results availand internationally. It does all the
able through a shared marketing
things a full-service ad agency
calendar that tracks retail offers
does: create ads, run marketing
and promotions.
campaigns, and track results.
The cloud is really about
But what differentiates the
doing what we have always been
firm is its comprehensive use of
doing, but doing it better, more
market intelligence.
professionally, and faster than
Adam Kanzmeier, Director of Customer Intelligence and
Strategic Consulting, Surdell and Partners
We gather lots of data from
we ever could before, Kanzmeier
our clients to figure out which
says. Retailers want to know
offers actually work, Kanzmeier
immediately how their camsays. This entails SaaS solutions for managing spending, campaigns are working. We look at their projections for each ad and then
paigns, and promotions. We analyze marketing data to figure out
we match the projections with actual sales to see how well each ad
how we can do what we do a lot better.
is doing. Each client now has a portal, which is basically a window
into our Oracle Database, which we built as an Oracle Application
MIGRATE TO THE CLOUD
Express interface.
Cloud computing is now broadly accepted as an economical way for
companies to share a pool of computing resources. Some 87 percent USING FAMILIAR TOOLS
of the businesses that participated in a recent Computerworld study
Surdell and Partners found the migration to Oracle Database Cloud
said they look to cloud initiatives to lower capital expenses, and
Service to be relatively straightforward. The firm used Oracle SQL
84 percent of them do so to reduce operational expenses. Many of
Developer and Oracle Application Express to move its data and busithese companies are moving key workloads to public clouds to take
ness processes to Oracle Cloud. At press time, the firm had already
advantage of rapid implementation options, dynamic scalability,
migrated one key application and was in the process of migrating all
and subscription-based pricing models.
its production applications to Oracle Cloud, Kanzmeier says.
Cloud computing is about getting there quickly, says Dom
In addition to the simplicity that comes with moving IT infraLindars, a cloud architect at Oracle. Its about allowing IT teams
structure off premises, his team has seen indirect benefits. We
to focus on strategic activities rather than
having to deal with database administration
or application maintenance. Most teams
save a lot of money by automating or eliminating these administrative tasks.
The Oracle Cloud platform makes
Oracles proven database and middleware
technologies available in an on-demand,
subscription-based, fully managed environment. Customers are assured full portability of applications and data between on
premises and cloud environments, with the
flexibility to change their hosting arrangements at any time.
For example, Surdell and Partners is
adopting Oracle Database 12c and its Oracle
Multitenant option, which enables their
Oracle database to function as a multitenant container database, with separate
pluggable databases for each client. A
single multitenant container database can
host and manage hundreds of pluggable
databasesa major step forward in cost
and convenience. That setup works well for
the firms SaaS solution, which processes
Zamil Industrial has seen the benefits of more than 15 systems and environments in the cloud. No company
can ignore the cloud anymore. Its not an option. Its a direction, says CIO Zaki Sabbagh.
and aggregates reams of client data about
28
ISV Apps
Run Better
on Exadata
30x Lower CPU Utilization
19x More Registrations
4x Less Storage Used
90% Linear Scalability
15x Faster MDM Throughput
70:1 Compression
30x More Scalable
oracle.com/exadata
Copyright 2015, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates.
Other names may be trademarks of their respective owners.
Mobile Developer
31
32
Target URLhttp://127.0.0.1:7101/
HrRestServices/
33
34
35
.inputValue}"/>
</dvtm:pointDataLayer>
</dvtm:geographicMap>
NEXT STEPS
DOWNLOAD the sample applications for
this article
bit.ly/omagmaf2
READ more about Oracle Mobile Application
Framework
oracle.com/maf
WATCH Oracle Mobile Application
Framework YouTube training
youtube.com/user/OracleMobilePlatform
JOIN the Oracle Mobile Application
Framework Google+ community
bit.ly/1A4h5sd
Go to where the
conversation lives.
Connect with Oracle Magazine on your favorite social
channel and be a part of our growing community.
Join Us.
OracleMagazine
Oracle Magazine
@OracleMagazine
Copyright 2013, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
ORACLE DATABASE
On Cursors, Context
Switches, and Mistakes
I-HUA CHEN
CRITICIZE CONSTRUCTIVELY
Theres no shortage of ways to improve
Marshas programjust as there is no
shortage of ways to improve many of
the packages and subprograms that I
(TMWKOP) have written over the years.
For Marshas program, I put together
two lists in my head: first, the list of things
Marsha has done well and for which she
should be complimented and, second, the
list of areas of concern, of what could be
improved. I then carefully filtered and organized the latter to maximize the impact.
Marsha, I started, I love your programmer instincts. They are on target
and will serve you well. You recognize that
keeping code volume to a minimum is generally a solid goal to aim for. Acting on that
principle, you found a way to avoid a declaration by using the cursor FOR loop. Before
writing all the logic in your program, you
also checked around to see if someone else
had beaten you to it: was the algorithm
or the information you needed already
implemented? I wish that more PL/SQL
37
38
PL/SQL
39
BEGIN
FOR indx IN 1 .. 1
LOOP
DBMS_OUTPUT.put_line (indx);
END LOOP;
END;
Good lazy: hide a SELECT behind a function to avoid having to type it more than
once. Bad lazy: abusing a language construct
so that Oracle Database will declare a variable
for you. Marsha looked a little embarrassed.
Oh, and by the way, I told Marsha,
theres another problem with using a cursor
FOR loop this way: you might hide a bug.
DONT HIDE POSSIBLE BUGS
Every program a developer writes makes
an assumption. When that assumption
fails, the program usually fails with an error.
Thats bad enough. Even worse, however,
a.
CREATE OR REPLACE FUNCTION plch_meme_title (
meme_id_in
IN plch_memes.meme_id%TYPE)
RETURN VARCHAR2
IS
l_return
plch_memes.title%TYPE;
BEGIN
SELECT title
INTO l_return
FROM plch_memes
WHERE meme_id = meme_id_in;
RETURN l_return;
END;
/
b.
CREATE OR REPLACE FUNCTION plch_meme_title (
meme_id_in
IN plch_memes.meme_id%TYPE)
RETURN VARCHAR2
IS
CURSOR title_cur
IS
SELECT title
FROM plch_memes
WHERE meme_id = meme_id_in;
l_return
plch_memes.title%TYPE;
BEGIN
OPEN title_cur;
FETCH title_cur INTO l_return;
CLOSE title_cur;
RETURN l_return;
END;
/
c.
CREATE OR REPLACE FUNCTION plch_meme_title (
meme_id_in
IN plch_memes.meme_id%TYPE)
RETURN VARCHAR2
IS
BEGIN
FOR rec IN (SELECT title
FROM plch_memes
WHERE meme_id = meme_id_in)
LOOP
RETURN rec.title;
END LOOP;
END;
/
40
PL/SQL
oritized reuse, but at the expense of performance and increased complexity of code.
So, I continued, lets talk about
context switches.
The PL/SQL language is tightly integrated
syntactically with SQL: you can write native
SQL statements inside PL/SQL, and almost
all built-in SQL functions are also available
as native PL/SQL functions.
But when it comes to executing PL/SQL
code and executing SQL statements, you
are looking at two different engines. The
PL/SQL runtime engine executes PL/SQL
blocks and the statements within them. The
SQL engine executes SQL statements.
Thats straightforward enough, right?
I asked Marsha. She nodded. But then it
gets tricky. What happens when the PL/SQL
engine encounters a SQL statement smackdab in the middle of the PL/SQL block?
Marsha thought about it for a moment. I
guess it must hand over the SQL statement
to the SQL engine for processing.
Exactly right! Its called a context switch.
The PL/SQL engine passes the SQL statement, along with bind variable values, over
to the SQL engine. The SQL engine does
its thing and then passes the results back
to the PL/SQL engine, which continues
right along.
41
Steven Feuerstein
(steven.feuerstein@
oracle.com) is an
architect for Oracle,
specializing in PL/SQL.
He also leads a team
of Oracle developer advocates. Feuersteins
books, such as Oracle PL/SQL Programming,
and more than a thousand PL/SQL quizzes at
PL/SQL Challenge (plsqlchallenge.com) provide
in-depth resources for PL/SQL developers.
NEXT STEPS
DOWNLOAD
Oracle Database 12c
bit.ly/fherki
PL/SQL code for this article
bit.ly/plsqlja15
TEST your PL/SQL knowledge
plsqlchallenge.com
READ more Feuerstein
bit.ly/omagplsql
READ more about PL/SQL
oracle.com/plsql
Last Chance to
Convert to Digital
And receive your Tom Kyte
collectors edition button!*
Copyright 2015, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates.
Other names may be trademarks of their respective owners. *Subject to digital subscription approval. While supplies last.
DBA
ORACLE DATABASE
Beginning Performance
Tuning: Trace Your Steps
Trace sessions to document activity details and
identify bottlenecks.
43
44
TUNING
from v$session
where username = 'SH';
=> true,
binds
=> true
plan_stat
=> 'all_executions');
end;
... output
SELECT
FROM
,
WHERE
AND
truncated ...
sum(s.amount_sold) AS dollars
sales s
times t
s.time_id = t.time_id
t.calendar_month_desc = '1998-05'
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.01
0
3
0
1
total
4
0.00
0.01
0
3
0
1
aggregate=no width=180
TRACEFILE_NAME
C:\APP\ORACLE\diag\rdbms\ANN1\ann1\
trace\ann1_ora_11408.trc
For UNIX-based systems, replace backslashes (\) with forward slashes (/) in the
tfname.sql script. In this case, the trace
filenamed ann1_ora_11408.trcis generated in the C:\APP\ORACLE\diag\rdbms\
ANN1\ann1\trace folder. Because of its size,
I am not showing the entire trace file here,
but you can download it from the Oraclehosted online version of this article, at
bit.ly/omagdbatrc715.
ANALYSIS
Examining a raw trace file can be overwhelming. To glean useful information from
it quickly, convert it to a format you can
easily interpret.
Oracle Database provides a tool called
tkprof for this very purpose. It accepts a
45
truncated ...
sum(s.amount_sold) AS dollars
sales s
times t
s.time_id = t.time_id
t.calendar_month_desc = 1998-05
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.05
0
24485
0
1
total
4
0.00
0.05
0
24485
0
1
Rows (1st) Rows (avg) Rows (max) Row Source Operation
1
1
1 SORT AGGREGATE (cr=24485 pr=0 pw=0 time=50655 us)
12309
12309
12309 HASH JOIN (cr=24485 pr=0 pw=0 time=58765 us cost=665 size=536284 card=19153)
12309
12309
12309
NESTED LOOPS (cr=24485 pr=0 pw=0 time=53432 us cost=665 size=536284 card=19153)
12309
12309
12309
NESTED LOOPS (cr=90 pr=0 pw=0 time=5826 us cost=665 size=536284 card=19153)
31
31
31
STATISTICS COLLECTOR (cr=56 pr=0 pw=0 time=283 us)
31
31
31
TABLE ACCESS FULL TIMES (cr=56 pr=0 pw=0 time=71 us cost=18 size=480 card=30)
12309
12309
12309
PARTITION RANGE ITERATOR PARTITION: KEY KEY (cr=34 pr=0 pw=0 time=4410 us)
12309
12309
12309
BITMAP CONVERSION TO ROWIDS (cr=34 pr=0 pw=0 time=2258 us)
31
31
31
BITMAP INDEX SINGLE VALUE SALES_TIME_BIX PARTITION: KEY KEY (cr=34 pr=0 pw=0
time=299 us)(object id 92695)
12309
12309
12309
TABLE ACCESS BY LOCAL INDEX ROWID SALES PARTITION: 1 1 (cr=24395 pr=0 pw=0
time=37669 us cost=665 size=7548 card=629)
0
0
0
PARTITION RANGE JOIN-FILTER PARTITION: :BF0000 :BF0000 (cr=0 pr=0 pw=0 time=0
us cost=665 size=7548 card=629)
0
0
0
TABLE ACCESS FULL SALES PARTITION: :BF0000 :BF0000 (cr=0 pr=0 pw=0 time=0
us cost=665 size=7548 card=629)
... output truncated ...
time=61 us)
RESOLUTION
Now lets see how to use the trace file
information to solve the original problem.
Listing 4 includes another excerpt of the
same ann1_ora_11408.out tkprof output file.
Examine the outputs in Listings 3 and 4,
and notice that the
46
TUNING
FUTURE SESSIONS
In the preceding sections, you learned how
to enable tracing in any session, provided
that you know the SID and serial# of that
session. When a new session is created,
however, it may have already performed
some activity by the time you get its SID and
serial# and execute the DBMS_MONITOR_
SESSION.SESSION_TRACE_ENABLE procedure. In that case, the already-performed
activities will not have been captured by
tracing, but these very activities could be
the cause of the performance issues. How
do you capture them? You need to enable
tracing for sessions that do not exist yet,
and the DBMS_MONITOR package provides
a procedure for that.
To enable tracing on sessions that dont
exist yet, you first need to know the service
name the session uses while connecting.
For this example, suppose the service
name is APP. You execute the following
SQL statement:
begin
dbms_monitor.serv_mod_act_trace_enable
(
service_name => APP,
action_name
=> dbms_monitor
waits
=> true,
binds
=> true
.all_actions,
);
end;
trcsess
47
CONCLUSION
Tracing enables you to capture all the activities performed by the session and the corresponding performance metrics at a very
granular level, which reveals trouble spots
that are otherwise not visible in session-level
metrics. Tuning features and tools enable
you to create human-readable files from
raw trace files and enable tracing on future
sessions, and they help you extract relevant
NEXT STEPS
READ more on tracing
bit.ly/1zGacmm
READ more Nanda
bit.ly/omagnanda
DOWNLOAD Oracle Database 12c
bit.ly/epBiUG
ORACLE DATABASE
I-HUA CHEN
compress
as
5
6
from cities_state
/
Table created.
HISTOGRAM
NONE
NONE
NOTES
STATS_ON_LOAD
STATS_ON_LOAD
49
50
ASK TOM
from (
select state,
count(*) cnt
from people
group by state
order by state
9
10
CNT
Alabama
Alaska
Arizona
Arkansas
California
STATE
rowsinstead. I knew that, but the optimizer didnt. Furthermore, this skew would
happen with other states as well, as shown
in Listing 3.
In this case, given the information it has
access tothe current set of statisticsthe
optimizer underestimates the number of
rows by an order of magnitude. As I pointed
out in my November/December 2014 column,
when the optimizer is off by orders of magnitude, the possibility of a bad plan is very high,
so the skew in Listing 3 is cause for concern.
So, what can you or I do about it? For a
query this simplea single-table query
with a single-column predicateI might
only need to gather statistics again. Since
1,139,854
291,825
4,130,606
667,541
25,145,815
291,825
SQL> select *
2
from table
3
(dbms_xplan.display_cursor
4
(format=>'allstats last')
5
)
6 /
| Id | Operation
| Name
| Starts | E-Rows | A-Rows |
|
0 | SELECT STATEMENT
|
|
1 |
|
1 |
|
1 | SORT AGGREGATE
|
|
1 |
1 |
1 |
|* 2 |
TABLE ACCESS FULL| PEOPLE |
1 |
2293K|
291K|
Code Listing 3: Plan statistics for a different state and more skew
SQL> select /*+ gather_plan_statistics */ count(*)
2
from people
3
where state = 'California'
4 /
COUNT(*)
25,145,815
| Id | Operation
| Name
| Starts | E-Rows | A-Rows |
|
0 | SELECT STATEMENT
|
|
1 |
|
1 |
|
1 | SORT AGGREGATE
|
|
1 |
1 |
1 |
|* 2 |
TABLE ACCESS FULL| PEOPLE |
1 |
2293K|
25M|
51
num_distinct,
histogram
4
5
6
from user_tab_col_statistics
675 NONE
50 FREQUENCY
291,825
| Id | Operation
| Name
| Starts | E-Rows | A-Rows |
|
0 | SELECT STATEMENT
|
|
1 |
|
1 |
|
1 | SORT AGGREGATE
|
|
1 |
1 |
1 |
|* 2 |
TABLE ACCESS FULL| PEOPLE |
1 |
291K|
291K|
25,145,815
| Id | Operation
| Name
| Starts | E-Rows | A-Rows |
|
0 | SELECT STATEMENT
|
|
1 |
|
1 |
|
1 | SORT AGGREGATE
|
|
1 |
1 |
1 |
|* 2 |
TABLE ACCESS FULL| PEOPLE |
1 |
25M|
25M|
291,825
SQL> exec dbms_stats.gather_table_stats( user, 'PEOPLE', no_invalidate=>FALSE );
PL/SQL procedure successfully completed.
SQL> select column_name,
2
num_distinct,
3
num_nulls,
4
histogram,
5
notes
6
from user_tab_col_statistics
7
where table_name = 'PEOPLE'
8 /
COLUMN_NAM NUM_DISTINCT
NUM_NULLS HISTOGRAM
NOTES
CITY_NAME
675
0 HYBRID
STATE
50
0 FREQUENCY
52
ASK TOM
| Id | Operation
| Name
| Starts | E-Rows | A-Rows |
|
0 | SELECT STATEMENT
|
|
1 |
|
1 |
|
1 | SORT GROUP BY NOSORT|
|
1 |
671K|
1 |
|* 2 |
TABLE ACCESS FULL | PEOPLE |
1 |
671K|
8175K|
Code Listing 7: New estimate on two-column predicate reoptimized with statistics feedback
SQL> select /*+ gather_plan_statistics */ city_name, state, count(*)
2
from people
3
where city_name = 'New York City'
4
and state = 'New York'
5
group by city_name, state
6 /
CITY_NAME
STATE
COUNT(*)
New York City New York
8,175,132
| Id | Operation
| Name
| Starts | E-Rows | A-Rows |
|
0 | SELECT STATEMENT
|
|
1 |
|
1 |
|
1 | SORT GROUP BY NOSORT|
|
1 |
8175K|
1 |
|* 2 |
TABLE ACCESS FULL | PEOPLE |
1 |
8175K|
8175K|
Note
CITY_NAME
STATE
OBJECT
COLUMN
COLUMN
TABLE
TYPE
DYNAMIC_SAMPLING
DYNAMIC_SAMPLING
DYNAMIC_SAMPLING
STATE
USABLE
USABLE
USABLE
REASON
53
3,792,620
| Id | Operation
| Name
| Starts | E-Rows | A-Rows |
|
0 | SELECT STATEMENT
|
|
1 |
|
1 |
|
1 | SORT AGGREGATE
|
|
1 |
1 |
1 |
|* 2 |
TABLE ACCESS FULL| PEOPLE |
1 |
5756K|
3792K|
Note
54
ASK TOM
NEXT STEPS
FOLLOW Tom on Twitter
@OracleAskTom
READ more Tom
bit.ly/omagasktom
Expert Oracle Database Architecture,
Third Edition
bit.ly/kyteexpert
DOWNLOAD Oracle Database 12c
bit.ly/epBiUG
LEARN more about Oracle Database 12c
oracle.com/database
cybernoor.com
925.924.0400
56
Since I started
working with
the organization
[ODTUG], weve
basically tripled
in size.
Monty Latiolais, ODTUG President
NEXT STEPS
LEARN more about ODTUG
odtug.com
READ more Latiolais
montylatiolais.blogspot.com
PAUL S. HOWELL
REGISTER NOW
Applications
Platform
as a Service
Engineered
Systems
Security
Mobile
Register at oracle.com/openworld
Copyright 2015, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates.
Global Sponsor
Innovation Sponsor
Premier Sponsors
Grande Sponsor