blob: da0dde1cced1b6bfc62fe2135ccdc2520331905f [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<title>Monitoring and Optimizing EclipseLink-Enabled Applications | EclipseLink 2.7 Understanding EclipseLink</title>
<meta name="generator" content="Oracle DARB XHTML Converter (Mode = document) - Version 1.0.22 Build 1" />
<meta name="date" content="2014-06-10T10:35:15Z" />
<meta name="robots" content="noarchive" />
<meta name="doctitle" content="Monitoring and Optimizing EclipseLink-Enabled Applications" />
<meta name="relnum" content="Release 2.7" />
<link rel="stylesheet" type="text/css" href="../../dcommon/style.css" media="screen" />
<link rel="copyright" href="../../dcommon/html/cpyr.htm" title="Copyright" type="text/html" />
<link rel="start" href="../../index.htm" title="Home" type="text/html" />
<link rel="contents" href="toc.htm" title="Contents" type="text/html" />
<link rel="prev" href="performance001.htm" title="Previous" type="text/html" />
<link rel="next" href="restful_jpa.htm" title="Next" type="text/html" />
<!-- START: Disqus --><script type="text/javascript"> var disqus_developer = 0; </script><!-- END: Disqus --><!-- START: Sharethis --><script type="text/javascript">var switchTo5x=true;</script><script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script><script type="text/javascript" src="http://s.sharethis.com/loader.js"></script> <!-- END: Sharethis --></head>
<body bgcolor="#FFFFFF"><iframe id="docheader" frameborder="0" framemargin="0" scrolling="no" src="../../dcommon/header.html"></iframe><script src="http://www.google.com/jsapi" type="text/javascript"></script><script type="text/javascript"> google.load('search', '1', {language : 'en'}); google.setOnLoadCallback(function() { var customSearchOptions = {}; var googleAnalyticsOptions = {}; googleAnalyticsOptions['queryParameter'] = 'q'; googleAnalyticsOptions['categoryParameter'] = ''; customSearchOptions['googleAnalyticsOptions'] = googleAnalyticsOptions; var customSearchControl = new google.search.CustomSearchControl( '016171230611334810008:enkkfjmsqju', customSearchOptions); customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET); var options = new google.search.DrawOptions(); options.setSearchFormRoot('cse-search-form'); customSearchControl.draw('cse', options); }, true);</script><link rel="stylesheet" href="http://www.google.com/cse/style/look/default.css" type="text/css" /><div id="cse" style="width:100%;"></div>
<div class="header"><a id="top" name="top"></a>
<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td align="left" valign="top"><font face="helvetica, arial, sans-serif"><b>EclipseLink Solutions Guide for EclipseLink</b><br />
Release 2.7</div></td>
<td valign="bottom" align="right" width="144">
<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td>&nbsp;</td>
<td align="center" valign="top"><a href="toc.htm"><img src="../../dcommon/images/contents.png" alt="Go To Table Of Contents" border="0" height="16" width="16" /><br />
</td><td>&nbsp;</td><td align="center"><a href="../../" target="_top" class="external text" title="Search" rel="nofollow"><img src="../../dcommon/images/search.png" alt="Search" style="border:0;" /><br /><span class="mini"></span></a></td><td>&nbsp;</td><td align="center"><a href="../eclipselink_otlcg.pdf" title="PDF" target="_blank"><img src="../../dcommon/images/pdf_icon.png" style="padding-right:5px;border:0" alt="PDF"></a></td>
</tr>
</table>
</td>
</tr>
</table>
<hr />
<table class="navigation simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100" align="center">
<tr>
<td align="center"><a href="performance001.htm"><img src="../../dcommon/images/larrow.png" alt="Previous" border="0" height="16" width="16" /></a></td>
<td align="center"><a href="restful_jpa.htm"><img src="../../dcommon/images/rarrow.png" alt="Next" border="0" height="16" width="16" /></a></td>
<td>&nbsp;</td>
</tr>
</table>
</div>
<!-- class="header" -->
<div class="ind"><!-- End Header --><a id="CHDFIECF" name="CHDFIECF"></a><a id="TLADG438" name="TLADG438"></a>
<div class="sect1"><!-- infolevel="all" infotype="General" -->
<h1 class="sect1"><font face="arial, helvetica, sans-serif" color="#330099">Monitoring and Optimizing EclipseLink-Enabled Applications</font></h1>
<p>The most important challenge to performance tuning is knowing what to optimize. To improve the performance of your application, identify the areas of your application that do not operate at peak efficiency. This section contains information about these subjects:</p>
<ul>
<li>
<p><a href="#CHDJJDDH">Performance Optimization Recommendations and Tips</a></p>
</li>
<li>
<p><a href="#CHDIAFJI">Task 1: Measure EclipseLink Performance with the EclipseLink Profiler</a></p>
</li>
<li>
<p><a href="#CIAFFAIF">Task 2: Measure EclipseLink Performance in the Server Environment</a></p>
</li>
<li>
<p><a href="#CIAFGJHI">Task 3: Measure Fetch Group Field Usage</a></p>
</li>
<li>
<p><a href="#CHDICBBA">Task 4: Identify Sources of Application Performance Problems</a></p>
</li>
<li>
<p><a href="#CHDDCABJ">Task 5: Modify Poorly-Performing Application Components</a></p>
</li>
<li>
<p><a href="#CHDHGFDI">Task 6: Measure Performance Again</a></p>
</li>
</ul>
<a id="CHDJJDDH" name="CHDJJDDH"></a><a id="TLADG439" name="TLADG439"></a>
<div class="sect2">
<h2 class="sect2"><font face="arial, helvetica, sans-serif" color="#330099">Performance Optimization Recommendations and Tips</font></h2>
<p>EclipseLink provides a diverse set of features to measure and optimize application performance. You can enable or disable most features in the descriptors or session, making any resulting performance gains global.Performance considerations are present at every step of the development cycle. Although this implies an awareness of performance issues in your design and implementation, it does not mean that you should expect to achieve the best possible performance in your first pass.</p>
<p>For example, if optimization complicates the design, leave it until the final development phase. You should still plan for these optimizations from your first iteration, to make them easier to integrate later.</p>
<p>The most important concept associated with tuning your EclipseLink application is the idea of an iterative approach. The most effective way to tune your application is to do the following tasks:</p>
<ul>
<li>
<p><a href="#CHDIAFJI">Task 1: Measure EclipseLink Performance with the EclipseLink Profiler</a>.</p>
</li>
<li>
<p><a href="#CIAFFAIF">Task 2: Measure EclipseLink Performance in the Server Environment</a></p>
</li>
<li>
<p><a href="#CIAFGJHI">Task 3: Measure Fetch Group Field Usage</a></p>
</li>
<li>
<p><a href="#CHDICBBA">Task 4: Identify Sources of Application Performance Problems</a>.</p>
</li>
<li>
<p><a href="#CHDDCABJ">Task 5: Modify Poorly-Performing Application Components</a>.</p>
</li>
<li>
<p><a href="#CHDHGFDI">Task 6: Measure Performance Again</a>.</p>
</li>
</ul>
</div>
<!-- class="sect2" -->
<a id="CHDIAFJI" name="CHDIAFJI"></a><a id="TLADG440" name="TLADG440"></a>
<div class="sect2">
<h2 class="sect2"><font face="arial, helvetica, sans-serif" color="#330099">Task 1: Measure EclipseLink Performance with the EclipseLink Profiler</font></h2>
<p>The EclipseLink performance profiler helps you identify performance problems by logging performance statistics for every executed query in a given session. Use the performance profiler to monitor a single query, or simple single-threaded use case.</p>
<p>The EclipseLink performance profiler logs the following information to the log file.</p>
<div class="tblhruleformal"><a id="TLADG441" name="TLADG441"></a><a id="sthref146" name="sthref146"></a><a id="sthref147" name="sthref147"></a>
<p><strong><em><font face="arial, helvetica, sans-serif">Table 18-1 Information Logged by the EclipseLink Performance Profiler</font></em></strong></p>
<table class="HRuleFormal" title="Information Logged by the EclipseLink Performance Profiler" summary="This is a two-column table. The left-hand column lists the type of information logged and the right-hand column describes that information." dir="ltr" border="1" width="100%" frame="hsides" rules="rows" cellpadding="3" cellspacing="0">
<col width="31%" />
<col width="*" />
<thead>
<tr align="left" valign="top">
<th align="left" valign="bottom" id="r1c1-t3"><font face="Arial, Helvetica, sans-serif"><strong>Information Logged</strong></font></th>
<th align="left" valign="bottom" id="r1c2-t3"><font face="Arial, Helvetica, sans-serif"><strong>Description</strong></font></th>
</tr>
</thead>
<tbody>
<tr align="left" valign="top">
<td align="left" id="r2c1-t3" headers="r1c1-t3">
<p>Query Class</p>
</td>
<td align="left" headers="r2c1-t3 r1c2-t3">
<p>Query class name.</p>
</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r3c1-t3" headers="r1c1-t3">
<p>Domain Class</p>
</td>
<td align="left" headers="r3c1-t3 r1c2-t3">
<p>Domain class name.</p>
</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r4c1-t3" headers="r1c1-t3">
<p>Total Time</p>
</td>
<td align="left" headers="r4c1-t3 r1c2-t3">
<p>Total execution time of the query, including any nested queries (in milliseconds).</p>
</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r5c1-t3" headers="r1c1-t3">
<p>Local Time</p>
</td>
<td align="left" headers="r5c1-t3 r1c2-t3">
<p>Execution time of the query, excluding any nested queries (in milliseconds).</p>
</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r6c1-t3" headers="r1c1-t3">
<p>Number of Objects</p>
</td>
<td align="left" headers="r6c1-t3 r1c2-t3">
<p>The total number of objects affected.</p>
</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r7c1-t3" headers="r1c1-t3">
<p>Number of Objects Handled per Second</p>
</td>
<td align="left" headers="r7c1-t3 r1c2-t3">
<p>How many objects were handled per second of transaction time.</p>
</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r8c1-t3" headers="r1c1-t3">
<p>Logging</p>
</td>
<td align="left" headers="r8c1-t3 r1c2-t3">
<p>the amount of time spent printing logging messages (in milliseconds).</p>
</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r9c1-t3" headers="r1c1-t3">
<p>SQL Prepare</p>
</td>
<td align="left" headers="r9c1-t3 r1c2-t3">
<p>The amount of time spent preparing the SQL script (in milliseconds).</p>
</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r10c1-t3" headers="r1c1-t3">
<p>SQL Execute</p>
</td>
<td align="left" headers="r10c1-t3 r1c2-t3">
<p>The amount of time spent executing the SQL script (in milliseconds).</p>
</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r11c1-t3" headers="r1c1-t3">
<p>Row Fetch</p>
</td>
<td align="left" headers="r11c1-t3 r1c2-t3">
<p>The amount of time spent fetching rows from the database (in milliseconds)</p>
</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r12c1-t3" headers="r1c1-t3">
<p>Cache</p>
</td>
<td align="left" headers="r12c1-t3 r1c2-t3">
<p>The amount of time spent searching or updating the object cache (in milliseconds)</p>
</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r13c1-t3" headers="r1c1-t3">
<p>Object Build</p>
</td>
<td align="left" headers="r13c1-t3 r1c2-t3">
<p>The amount of time spent building the domain object (in milliseconds)</p>
</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r14c1-t3" headers="r1c1-t3">
<p>query Prepare</p>
</td>
<td align="left" headers="r14c1-t3 r1c2-t3">
<p>the amount of time spent to prepare the query prior to execution (in milliseconds)</p>
</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r15c1-t3" headers="r1c1-t3">
<p>SQL Generation</p>
</td>
<td align="left" headers="r15c1-t3 r1c2-t3">
<p>the amount of time spent to generate the SQL script before it is sent to the database (in milliseconds)</p>
</td>
</tr>
</tbody>
</table>
<br /></div>
<!-- class="tblhruleformal" -->
<a id="CHDDAEHF" name="CHDDAEHF"></a><a id="TLADG442" name="TLADG442"></a>
<div class="sect3">
<h3 class="sect3"><font face="arial, helvetica, sans-serif" color="#330099">Enabling the EclipseLink Profiler</font></h3>
<p>The EclipseLink performance profiler is an instance of <code>org.eclipse.persistence.tools.profiler.PerformanceProfiler</code> class. To enable it, add the following line to the <code>persistence.xml</code> file:</p>
<pre xml:space="preserve" class="oac_no_warn">
&lt;property name="eclipselink.profiler" value="PerformanceProfiler.logProfiler"/&gt;
</pre>
<p>In addition to enabling the EclipseLink profiler, The <code>PerformanceProfiler</code> class public API also provides the functionality described in <a href="#CHDGBGGC">Table 18-2</a>:</p>
<div class="tblhruleformal"><a id="TLADG443" name="TLADG443"></a><a id="sthref148" name="sthref148"></a><a id="CHDGBGGC" name="CHDGBGGC"></a>
<p><strong><em><font face="arial, helvetica, sans-serif">Table 18-2 Additional PerformanceProfiler Functionality</font></em></strong></p>
<table class="HRuleFormal" title="Additional PerformanceProfiler Functionality" summary="This is a two-column table. The left-hand column describes a condition you want to obtain and the right-hand column identifies the method to use to attain that condition." dir="ltr" border="1" width="100%" frame="hsides" rules="rows" cellpadding="3" cellspacing="0">
<col width="*" />
<col width="35%" />
<thead>
<tr align="left" valign="top">
<th align="left" valign="bottom" id="r1c1-t4"><font face="Arial, Helvetica, sans-serif"><strong>To...</strong></font></th>
<th align="left" valign="bottom" id="r1c2-t4"><font face="Arial, Helvetica, sans-serif"><strong>Use...</strong></font></th>
</tr>
</thead>
<tbody>
<tr align="left" valign="top">
<td align="left" id="r2c1-t4" headers="r1c1-t4">
<p>Disable the profiler</p>
</td>
<td align="left" headers="r2c1-t4 r1c2-t4">
<p><code>dontLogProfile</code></p>
</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r3c1-t4" headers="r1c1-t4">
<p>Organize the profiler log into a summary of all the individual operation profiles including operation statistics like the shortest time of all the operations that were profiled, the total time of all the operations, the number of objects returned by profiled queries, and the total time that was spent in each kind of operation that was profiled</p>
</td>
<td align="left" headers="r3c1-t4 r1c2-t4">
<p><code>logProfileSummary</code></p>
</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r4c1-t4" headers="r1c1-t4">
<p>Organize the profiler log into a summary of all the individual operation profiles by query</p>
</td>
<td align="left" headers="r4c1-t4 r1c2-t4">
<p><code>logProfileSummaryByQuery</code></p>
</td>
</tr>
<tr align="left" valign="top">
<td align="left" id="r5c1-t4" headers="r1c1-t4">
<p>Organize the profiler log into a summary of all the individual operation profiles by class.</p>
</td>
<td align="left" headers="r5c1-t4 r1c2-t4">
<p><code>logProfileSummaryByClass</code></p>
</td>
</tr>
</tbody>
</table>
<br /></div>
<!-- class="tblhruleformal" --></div>
<!-- class="sect3" -->
<a id="TLADG444" name="TLADG444"></a>
<div class="sect3"><a id="sthref149" name="sthref149"></a>
<h3 class="sect3"><font face="arial, helvetica, sans-serif" color="#330099">Accessing and Interpreting Profiler Results</font></h3>
<p>You can see profiling results by opening the profile log in a text reader, such as Notepad.</p>
<p>The profiler output file indicates the health of a EclipseLink-enabled application.</p>
<p><a href="#CHDBGFGG">Example 18-7</a> shows an sample of the EclipseLink profiler output.</p>
<div class="example"><a id="CHDBGFGG" name="CHDBGFGG"></a><a id="TLADG445" name="TLADG445"></a>
<p><strong><em><font face="arial, helvetica, sans-serif">Example 18-7 Performance Profiler Output</font></em></strong></p>
<pre xml:space="preserve" class="oac_no_warn">
Begin Profile of{
ReadAllQuery(com.demos.employee.domain.Employee)
Profile(ReadAllQuery,# of obj=12, time=139923809,sql execute=21723809,
prepare=49523809, row fetch=39023809, time/obj=11623809,obj/sec=8)
} End Profile
</pre></div>
<!-- class="example" -->
<p><a href="#CHDBGFGG">Example 18-7</a> shows the following information about the query:</p>
<ul>
<li>
<p><code>ReadAllQuery(com.demos.employee.domain.Employee)</code>: specific query profiled, and its arguments.</p>
</li>
<li>
<p><code>Profile(ReadAllQuery</code>: start of the profile and the type of query.</p>
</li>
<li>
<p><code># of obj=12</code>: number of objects involved in the query.</p>
</li>
<li>
<p><code>time=139923809</code>: total execution time of the query (in milliseconds).</p>
</li>
<li>
<p><code>sql execute=21723809</code>: total time spent executing the SQL statement.</p>
</li>
<li>
<p><code>prepare=49523809</code>: total time spent preparing the SQL statement.</p>
</li>
<li>
<p><code>row fetch=39023809</code>: total time spent fetching rows from the database.</p>
</li>
<li>
<p><code>time/obj=116123809</code>: number of nanoseconds spent on each object.</p>
</li>
<li>
<p><code>obj/sec=8</code>: number of objects handled per second.</p>
</li>
</ul>
</div>
<!-- class="sect3" --></div>
<!-- class="sect2" -->
<a id="CIAFFAIF" name="CIAFFAIF"></a><a id="TLADG1230" name="TLADG1230"></a>
<div class="sect2">
<h2 class="sect2"><font face="arial, helvetica, sans-serif" color="#330099">Task 2: Measure EclipseLink Performance in the Server Environment</font></h2>
<p>Use the Performance Monitor to provide detailed profiling and monitoring information in a multithreaded server environment. Use the performance monitor to monitor a server, multiple threads, or long running processes.</p>
<p>Enable the monitor in <code>persistence.xml</code> file as follows:</p>
<pre xml:space="preserve" class="oac_no_warn">
&lt;property name="eclipselink.profiler" value="PerformanceMonitor"/&gt;
</pre>
<p>The performance monitor can also be enabled through code using a <code>SessionCustomizer</code>.</p>
<p>The performance monitor will output a dump of cumulative statistics every minute to the EclipseLink log. The statistics contains three sets of information:</p>
<ul>
<li>
<p><strong>Info</strong>; statistics that are constant informational data, such as the session name, or time of login.</p>
</li>
<li>
<p><strong>Counter</strong>; statistics that are cumulative counters of total operations, such as cache hits, or query executions.</p>
</li>
<li>
<p><strong>Timer</strong>; statistics that are cumulative measurements of total time (in nano seconds) for a specific type of operation, reading, writing, database operations.</p>
</li>
</ul>
<p>Statistics are generally grouped in total and also by query type, query class, and query name. Counters and timers are generally recorded for the same operations, so the time per operation could also be calculated.</p>
<p>The time between statistic dumps can be configured by using the <code>setDumpTime(long)</code> method in the <code>PerformanceMonitor</code> class. If dumping the results is not desired, then the <code>dumpTime</code> attribute can be set to be very large such as <code>Long.MAX_VALUE</code>. The statistic can also be accessed in a Java program with the <code>getOperationTime(String)</code> method.</p>
<p>The performance monitor can also be configured with a profile weight. The profile weights are defined in the <code>SessionProfiler</code> class and used by the PerformanceMonitor class. The weights include:</p>
<ul>
<li>
<p><code>NONE</code>&mdash;No statistics are recorded.</p>
</li>
<li>
<p><code>NORMAL</code>&mdash;Informational statistics are recorded.</p>
</li>
<li>
<p><code>HEAVY</code>&mdash;Informational, counter and timer statistics are recorded.</p>
</li>
<li>
<p><code>ALL</code>&mdash;All statistics are recorded (this is the default).</p>
<div align="center">
<div class="inftblnote"><br />
<table class="Note oac_no_warn" summary="" border="1" width="80%" frame="hsides" rules="groups" cellpadding="3" cellspacing="0">
<tbody>
<tr>
<td align="left">
<p class="note"><img src="../../dcommon/images/note_icon.png" width="16" height="16" alt="Note" style="vertical-align:middle;padding-right:5px;" />Note:</p>
<p>In the current release, the performance monitor responds with the same information for the <code>HEAVY</code> and <code>ALL</code> values.</p>
</td>
</tr>
</tbody>
</table>
<br /></div>
<!-- class="inftblnote" --></div>
</li>
</ul>
</div>
<!-- class="sect2" -->
<a id="CIAFGJHI" name="CIAFGJHI"></a><a id="TLADG1231" name="TLADG1231"></a>
<div class="sect2"><!-- infolevel="all" infotype="General" -->
<h2 class="sect2"><font face="arial, helvetica, sans-serif" color="#330099">Task 3: Measure Fetch Group Field Usage</font></h2>
<p>Use the Fetch Group Monitor to measure fetch group field usage. This can be useful for performance analysis in a complex system.</p>
<p>Enable this monitor by using the system property <code>org.eclipse.persistence.fetchgroupmonitor=true</code>.</p>
<p>The monitor outputs the attribute used for a class every time a new attribute is accessed.</p>
</div>
<!-- class="sect2" -->
<a id="CHDICBBA" name="CHDICBBA"></a><a id="TLADG446" name="TLADG446"></a>
<div class="sect2">
<h2 class="sect2"><font face="arial, helvetica, sans-serif" color="#330099">Task 4: Identify Sources of Application Performance Problems</font></h2>
<p>Areas of the application where performance problems could occur include the following:</p>
<ul>
<li>
<p>Identifying General Performance Optimization</p>
</li>
<li>
<p>Schema</p>
</li>
<li>
<p>Mappings and Descriptors</p>
</li>
<li>
<p>Sessions</p>
</li>
<li>
<p>Cache</p>
</li>
<li>
<p>Data Access</p>
</li>
<li>
<p>Queries</p>
</li>
<li>
<p>Unit of Work</p>
</li>
<li>
<p>Application Server and Database Optimization</p>
</li>
</ul>
<p><a href="#CHDDCABJ">Task 5: Modify Poorly-Performing Application Components</a> provides some guidelines for dealing with problems in each of these areas.</p>
</div>
<!-- class="sect2" -->
<a id="CHDDCABJ" name="CHDDCABJ"></a><a id="TLADG447" name="TLADG447"></a>
<div class="sect2">
<h2 class="sect2"><font face="arial, helvetica, sans-serif" color="#330099">Task 5: Modify Poorly-Performing Application Components</font></h2>
<p>For each source of application performance problems listed in <a href="#CHDICBBA">Task 4: Identify Sources of Application Performance Problems</a>, you can try specific workarounds, as described in this section.</p>
<a id="TLADG448" name="TLADG448"></a>
<div class="sect3"><!-- infolevel="all" infotype="General" --><a id="sthref150" name="sthref150"></a>
<h3 class="sect3"><font face="arial, helvetica, sans-serif" color="#330099">Identifying General Performance Optimizations</font></h3>
<p><strong>Avoid overriding EclipseLink default behavior unless your application requires it</strong>. Some of these defaults are suitable for a development environment; you should change these defaults to suit your production environment. These defaults may include:</p>
<ul>
<li>
<p>Batch writing &ndash; See "jdbc.batch-writing" in <em>Java Persistence API (JPA) Extensions Reference for EclipseLink</em>.</p>
</li>
<li>
<p>Statement caching &ndash; See "jdbc.cache-statements" in <em>Java Persistence API (JPA) Extensions Reference for EclipseLink</em>.</p>
</li>
<li>
<p>Read and write connection pool size &ndash; See "connection-pool" in <em>Java Persistence API (JPA) Extensions Reference for EclipseLink</em>.</p>
</li>
<li>
<p>Session cache size &ndash; See "maintain-cache" in <em>Java Persistence API (JPA) Extensions Reference for EclipseLink</em>.</p>
</li>
</ul>
<p><strong>Use the Workbench rather than manual coding.</strong> These tools are not only easy to use: the default configuration they export to deployment XML (and the code it generates, if required) represents best practices optimized for most applications.</p>
</div>
<!-- class="sect3" -->
<a id="TLADG449" name="TLADG449"></a>
<div class="sect3"><!-- infolevel="all" infotype="General" --><a id="sthref151" name="sthref151"></a>
<h3 class="sect3"><font face="arial, helvetica, sans-serif" color="#330099">Schema</font></h3>
<p>Optimization is an important consideration when you design your database schema and object model. Most performance issues occur when the object model or database schema is too complex, as this can make the database slow and difficult to query. This is most likely to happen if you derive your database schema directly from a complex object model.</p>
<p>To optimize performance, design the object model and database schema together. However, allow each model to be designed optimally: do not require a direct one-to-one correlation between the two.</p>
<p>Possible ways to optimize the schema include:</p>
<ul>
<li>
<p>Aggregating two tables into one</p>
</li>
<li>
<p>Splitting one table into many</p>
</li>
<li>
<p>Using a collapsed hierarchy</p>
</li>
<li>
<p>Choosing one out of many</p>
</li>
</ul>
<p>See "Data Storage Schema" in <em>EclipseLink Concepts</em> for additional information.</p>
</div>
<!-- class="sect3" -->
<a id="TLADG450" name="TLADG450"></a>
<div class="sect3"><!-- infolevel="all" infotype="General" --><a id="sthref152" name="sthref152"></a>
<h3 class="sect3"><font face="arial, helvetica, sans-serif" color="#330099">Mappings and Descriptors</font></h3>
<p>If you find performance bottlenecks in your mapping and descriptors, try these solutions:</p>
<ul>
<li>
<p>Always use indirection (lazy loading). It is not only critical in optimizing database access, but also allows EclipseLink to make several other optimizations including optimizing its cache access and unit of work processing. See "cache-usage" in <em>Java Persistence API (JPA) Extensions Reference for EclipseLink</em>.</p>
</li>
<li>
<p>Avoid using method access in your EclipseLink mappings, especially if you have expensive or potentially dangerous side-effect code in your get or set methods; use the default direct attribute access instead. See "Using Method or Direct Field Access" in the <em>EclipseLink Concepts</em>.</p>
</li>
<li>
<p>Avoid using the existence checking option checkCacheThenDatabase on descriptors, unless required by the application. The default existence checking behavior offers better performance. See "@ExistenceChecking" in <em>Java Persistence API (JPA) Extensions Reference for EclipseLink</em>.</p>
</li>
<li>
<p>Avoid expensive initialization in the default constructor that EclipseLink uses to instantiate objects. Instead, use lazy initialization or use an EclipseLink instantiation policy to configure the descriptor to use a different constructor. See "@InstantiationCopyPolicy" in <em>Java Persistence API (JPA) Extensions Reference for EclipseLink</em>.</p>
</li>
</ul>
</div>
<!-- class="sect3" -->
<a id="TLADG452" name="TLADG452"></a>
<div class="sect3"><!-- infolevel="all" infotype="General" --><a id="sthref153" name="sthref153"></a>
<h3 class="sect3"><font face="arial, helvetica, sans-serif" color="#330099">Cache</font></h3>
<p>You can often improve performance through caching, even in a clustered environment by implementing cache coordination. Cache coordination allows multiple, possibly distributed instances of a session to broadcast object changes among each other so that each session's cache can be kept up-to-date. For detailed information about optimizing cache behavior, see "Understanding Caching" in <em>EclipseLink Concepts</em> and the following examples:</p>
<ul>
<li>
<p><code><a href="http://wiki.eclipse.org/EclipseLink/Examples/JPA/Caching">http://wiki.eclipse.org/EclipseLink/Examples/JPA/Caching</a></code></p>
</li>
<li>
<p><code><a href="http://wiki.eclipse.org/EclipseLink/Examples/JPA/CacheCoordination">http://wiki.eclipse.org/EclipseLink/Examples/JPA/CacheCoordination</a></code></p>
</li>
<li>
<p><code><a href="http://wiki.eclipse.org/EclipseLink/Examples/JPA/DCN">http://wiki.eclipse.org/EclipseLink/Examples/JPA/DCN</a></code></p>
</li>
</ul>
</div>
<!-- class="sect3" -->
<a id="TLADG453" name="TLADG453"></a>
<div class="sect3"><!-- infolevel="all" infotype="General" --><a id="sthref154" name="sthref154"></a>
<h3 class="sect3"><font face="arial, helvetica, sans-serif" color="#330099">Data Access</font></h3>
<p>Depending on the type of data source your application accesses, EclipseLink offers a variety of <code>Login</code> options that you can use to tune the performance of low level data reads and writes. For optimizing higher-level data reads and writes, "Understanding Data Access" in <em>EclipseLink Concepts</em> offers several techniques to improve data access performance for your application. These techniques show you how to:</p>
<ul>
<li>
<p>Optimize JDBC driver properties.</p>
</li>
<li>
<p>Optimize data format.</p>
</li>
<li>
<p>Use batch writing for optimization.</p>
</li>
<li>
<p>Use Outer-Join Reading with Inherited Subclasses.</p>
</li>
<li>
<p>Use Parameterized SQL (Parameter Binding) and Prepared Statement Caching for Optimization.</p>
</li>
</ul>
</div>
<!-- class="sect3" -->
<a id="TLADG454" name="TLADG454"></a>
<div class="sect3"><!-- infolevel="all" infotype="General" --><a id="sthref155" name="sthref155"></a>
<h3 class="sect3"><font face="arial, helvetica, sans-serif" color="#330099">Queries</font></h3>
<p>EclipseLink provides an extensive query API for reading, writing, and updating data. "Understanding EclipseLink Queries" in <em>EclipseLink Concepts</em> offers several techniques to improve query performance for your application. These techniques show you how to:</p>
<ul>
<li>
<p>Use parameterized SQL and prepared statement caching for optimization.</p>
</li>
<li>
<p>Use named queries for optimization.</p>
</li>
<li>
<p>Use batch and join reading for optimization.</p>
</li>
<li>
<p>Use partial object queries and fetch groups for optimization.</p>
</li>
<li>
<p>Use read-only queries for optimization.</p>
</li>
<li>
<p>Use JDBC fetch size for optimization.</p>
</li>
<li>
<p>Use cursored streams and scrollable cursors for optimization.</p>
</li>
<li>
<p>Use result set pagination for optimization.</p>
</li>
</ul>
<p>It also includes links to read and write optimization examples.</p>
</div>
<!-- class="sect3" -->
<a id="TLADG456" name="TLADG456"></a>
<div class="sect3"><!-- infolevel="all" infotype="General" --><a id="sthref156" name="sthref156"></a>
<h3 class="sect3"><font face="arial, helvetica, sans-serif" color="#330099">Application Server and Database Optimization</font></h3>
<p>To optimize the application server and database performance, consider these techniques:</p>
<ul>
<li>
<p>Configuring your application server and database correctly can have a big impact on performance and scalability. Ensure that you correctly optimize these key components of your application in addition to your EclipseLink application and persistence.</p>
</li>
<li>
<p>For your application or Java EE server, ensure your memory, thread pool and connection pool sizes are sufficient for your server's expected load, and that your JVM has been configured optimally.</p>
</li>
<li>
<p>Ensure that your database has been configured correctly for optimal performance and its expected load.</p>
</li>
</ul>
</div>
<!-- class="sect3" --></div>
<!-- class="sect2" -->
<a id="CHDHGFDI" name="CHDHGFDI"></a><a id="TLADG457" name="TLADG457"></a>
<div class="sect2">
<h2 class="sect2"><font face="arial, helvetica, sans-serif" color="#330099">Task 6: Measure Performance Again</font></h2>
<p>Finally, after identifying possible performance bottlenecks and taking some action on them, rerun your application, again with the profiler enabled (see <a href="#CHDDAEHF">Enabling the EclipseLink Profiler</a>). Review the results and, if more action is required, follow the procedures outlined in <a href="#CHDDCABJ">Task 5: Modify Poorly-Performing Application Components</a>.</p>
</div>
<!-- class="sect2" --></div>
<!-- class="sect1" --></div>
<!-- class="ind" -->
<!-- Start Footer -->
<div class="footer">
<hr />
<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%">
<col width="33%" />
<col width="*" />
<col width="33%" />
<tr>
<td valign="bottom">
<table class="navigation simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100" align="center">
<col width="*" />
<col width="48%" />
<col width="48%" />
<tr>
<td>&nbsp;</td>
<td align="center"><a href="performance001.htm"><img src="../../dcommon/images/larrow.png" alt="Previous" border="0" height="16" width="16" /></a></td>
<td align="center"><a href="restful_jpa.htm"><img src="../../dcommon/images/rarrow.png" alt="Next" border="0" height="16" width="16" /></a></td>
</tr>
</table>
</td>
<td align="center" width="34%"><a href="http://www.eclipse.org/eclipselink/" title="EclipseLink home"><img src="../../dcommon/images/ellogo.png" alt="EclipseLink" width="150" border="0" /></a><br />
<font size="-2">Copyright&nbsp;&copy;&nbsp;2014,&nbsp;Oracle&nbsp;and/or&nbsp;its&nbsp;affiliates.&nbsp;All&nbsp;rights&nbsp;reserved.</font> <a href="../../dcommon/html/cpyr.htm"><br />
<td valign="bottom" align="right">
<table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="225">
<tr>
<td>&nbsp;</td>
<td align="center" valign="top"><a href="toc.htm"><img src="../../dcommon/images/contents.png" alt="Go To Table Of Contents" border="0" height="16" width="16" /><br />
</td><td>&nbsp;</td><td align="center"><a href="../../" target="_top" class="external text" title="Search" rel="nofollow"><img src="../../dcommon/images/search.png" alt="Search" style="border:0;" /><br /><span class="mini"></span></a></td><td>&nbsp;</td><td align="center"><a href="../eclipselink_otlcg.pdf" title="PDF" target="_blank"><img src="../../dcommon/images/pdf_icon.png" style="padding-right:5px;border:0" alt="PDF"></a></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<!-- class="footer" -->
<div id="copyright">Copyright &copy; 2014 by The Eclipse Foundation under the <a href="http://www.eclipse.org/org/documents/epl-v10.php">Eclipse Public License (EPL)</a><br /> <script type="text/javascript">var LastUpdated = document.lastModified;document.writeln ("Updated: " + LastUpdated);</script> </div><!-- START: Analytics --><script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-1608008-2']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script><!-- END: Analytics --><!-- START: Sharethis --><script>var options={ "publisher": "e2fe9e07-fab6-4f84-83ea-0991b429842c", "position": "right", "ad": { "visible": false, "openDelay": 5, "closeDelay": 0}};var st_hover_widget = new sharethis.widgets.hoverbuttons(options);</script><!-- END: Sharethis --></body>
</html>