Performance Optimization - Adobe 38043740 - ColdFusion Standard - Mac Development Manual

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
ColdFusion ORM
/**
* @persistent
* @table Users
* @optimistic-lock all
*/
component{
property name="id" fieldtype="id" datatype="int" generator="native";
property string fname;
property string lname;
}
Apart from defining optimistic lock control at the CFC level, you can also define it at the property level using
'
' (true|false: default true) attribute.
optimisticlock
You can specify
optimisticlock=true
this attribute determines whether a version increment will occur when the property is dirty.
In case of one-to-many and many-to-many association, if the state of the collection changes, then version of the
corresponding entity is incremented. It is advised that you disable this setting for one-to-many associations.

Performance optimization

Lazy Loading
Optimizing SQL queries enhances the performance of any data-centric application. Some of the common approaches
used to optimize SQL queries are:
• Avoid round trips to the database and fetch all required data for an operation using a single SQL query using Joins.
• Fetch only required data to reduce the load on the database
SQL queries are generated and executed by the underlying ORM engine. Therefore, Hibernate provides various hooks
to optimize SQL. The fetching strategy is one of the most important hooks, which defines the data that to be fetched,
the time of fetching the data, and the way in which it needs to be fetched.
There are four strategies for loading an object and its associations.
• Immediate fetching
• Lazy fetching
• Eager fetching
• Batch fetching
Note: If memory tracking is enabled on a server, it accesses each field of the object to compute its size. As a result, even
lazy fields are accessed causing the lazy fields to get loaded immediately.
Immediate fetching
In this strategy, the associated object is fetched immediately after the owning entity is fetched, either from the database
using a separate SQL query or from the secondary cache. This is not an efficient strategy to use, unless the associated
object is cached in the secondary cache or when separate queries are more efficient than a Join query. You can define
this strategy by setting
lazy="false"
<cfproperty name="art" fieldtype="one-to-many" cfc="ART" fkcolumn="ARTISTID" lazy="false"
fetch="select">
for a property to acquire optimistic lock when the property is updated. Setting
and
for the relationship property definition in the CFC.
fetch="select"
Last updated 1/20/2012
587

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents