Jdbc And Database Access - Sun Microsystems Sun GlassFish Enterprise Server 2.1 Tuning Manual

Performance tuning guide
Hide thumbs Also See for Sun GlassFish Enterprise Server 2.1:
Table of Contents

Advertisement

EJB Performance Tuning
Pre-fetching generally improves performance because it reduces the number of database
accesses. However, if the business logic often uses Orders without referencing their OrderLines,
then this can have a performance penalty, that is, the system has spent the effort to pre-fetch the
OrderLines that are not actually needed.
Avoid pre-fetching for specific finder methods; this can often avoid that penalty. For example,
consider an order bean has two finder methods: a findByPrimaryKey method that uses the
orderlines, and a findByCustomerId method that returns only order information and hence
doesn't use the orderlines. If you've enabled CMR pre-fetching for the orderlines, both finder
methods will pre-fetch the orderlines. However, you can prevent pre-fetching for the
findByCustomerId method by including this information in the sun-ejb-jar.xml descriptor:
<ejb>
</ejb>

JDBC and Database Access

Here are some tips to improve the performance of database access.
Use JDBC Directly
When dealing with large amounts of data, such as searching a large database, use JDBC directly
rather than using Entity EJB components.
Encapsulate Business Logic in Entity EJB Components
Combine business logic with the Entity EJB component that holds the data needed for that logic
to process.
Close Connections
To ensure that connections are returned to the pool, always close the connections after use.
Minimize the Database Transaction Isolation Level
Use the default isolation level provided by the JDBC driver rather than calling
setTransactionIsolationLevel(), unless you are certain that your application behaves
correctly and performs better at a different isolation level.
46
Sun GlassFish Enterprise Server 2.1 Performance Tuning Guide • January 2009
<ejb-name>OrderBean</ejb-name>
...
<cmp>
<prefetch-disabled>
<query-method>
<method-name>findByCustomerId</method-name>
</query-method>
</prefetch-disabled>
</cmp>

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the Sun GlassFish Enterprise Server 2.1 and is the answer not in the manual?

Questions and answers

Table of Contents