![]() | ![]() |
![]() |
| Project | Ver 1.1 | Ver 1.2 | JDO | JPA | Guides | Tools |
| 1.1 | Preparation | O/R Mapping | Runtime | Extensions | Developer |
JPOX, by default, provides certain functionality. In particular circumstances some of this functionality may not be appropriate and it may be desirable to turn on or off particular features to gain more performance for the application in question. This section contains a few common tips
JPOX provides 4 PersistenceManagerFactory properties org.jpox.autoCreateSchema, org.jpox.autoCreateTables org.jpox.autoCreateColumns, and org.jpox.autoCreateConstraints that allow creation of the datastore tables. This can cause performance issues at startup. We recommend setting these to false at runtime, and instead using SchemaTool to generate any required database schema before running JPOX.
The creation of a PersistenceManagerFactory is expensive in terms of time. You should aim to use as few as possible, and preferably a single factory per datastore. You can also improve startup speed by setting the property org.jpox.autoStartMechanism to None. This means that it won't try to load up the classes (or better said the metadata of the classes) handled the previous time that this schema was used. If this isn't an issue for your application then you can make this change. Please refer to the Auto-Start Mechanism for full details. Some RDBMS (such as Oracle) have trouble returning information across multiple catalogs/schemas and so, when JPOX starts up and tries to obtain information about the existing tables, it can take some time. This is easily remedied by specifying the catalog/schema name to be used - either for the PMF as a whole (using the PMF properties javax.jdo.mapping.Catalog, javax.jdo.mapping.Schema) or for the package/class using attributes in the MetaData. This subsequently reduces the amount of information that the RDBMS needs to search through and so can give significant speed ups when you have many catalogs/schemas being managed by the RDBMS.
JPOX provides 3 PersistenceManagerFactory properties org.jpox.validateTables, org.jpox.validateConstraints org.jpox.validateColumns that enforce strict validation of the datastore tables against the Meta-Data defined tables. This can cause performance issues at startup. In general this should be run only at schema generation, and should be turned off for production usage. Set all of these properties to false. In addition there is a PMF property org.jpox.rdbms.CheckExistsTablesOrViews which checks whether the tables/views that the classes map onto are present in the datastore. This could also be set to false if you require fast start-up.
JPOX, by default, will allocate connections when they are required. It then will close the connection. In addition, when it needs to perform something via JDBC it will allocate a PreparedStatement, and then discard the statement after use. This can be inefficient relative to a database connection and statement pooling facility such as Apache DBCP. With Apache DBCP a Connection is allocated when required and then when it is closed the Connection isn't actually closed but just saved in a pool for the next request that comes in for a Connection. This saves the time taken to establish a Connection and hence can give performance speed ups the order of maybe 30% or more. You can read about how to enable connection pooling with JPOX in the Connection Pooling Guide.
JPOX verifies if newly persisted objects are memory reachable on commit, if they are not, they are removed from the database. This process mirrors the garbage collection, where objects not referenced are garbage collected or removed from memory. Reachability is expensive because it traverses the whole object tree and may require reloading data from database. If reachability is not needed by your application, you should disable it. To disable reachability set to false the PMF property org.jpox.persistenceByReachabilityAtCommit.
JPOX provides a series of identity generators (POID Generators) for generation of identity values. These can have an impact on the performance depending on the choice of generator, and also on the configuration of the generator.
The native identity generator value is the recommended choice since this will allow JPOX to decide which identity generator is best for the RDBMS in use.
![]() JPOX has 2 ways of handling calls to SCO Collections/Maps. The original method (the default until 1.1.0-beta-1) was to pass all calls through to the datastore. The second method (which is now the default) is to cache the collection/map elements/keys/values. This second method will read the elements/keys/values once only and thereafter use the internally cached values. This second method gives significant performance gains relative to the original method. You can configure the handling of collections/maps as follows :-
The second method also allows a finer degree of control. This allows the use of lazy loading of data, hence elements will only be loaded if they are needed. You can configure this as follows :-
NontransactionalRead has advantages and disadvantages in performance and data freshness in cache. In NontransactionalRead=true mode, the PersistenceManager is able to read objects outside a transaction. The objects read are held cached by the PersistenceManager. The second time a user application requests the same objects from the PersistenceManager they are retrieved from cache. The time spent reading the object from cache is minimum, but the objects may become stale and not represent the database status. If fresh values need to be loaded from the database, then the user application should first call refresh on the object. Another disadvantage of NontransactionalRead=true mode is due to each operation realized opens a new database connection, but it can be minimized with the use of connection pools.
Reading objects outside a transaction and PersistenceManager is a trivial task, but performed in a certain manner can determine the application performance. The objective here is not give you an absolute response on the subject, but point out the benefits and drawbacks for the many possible solutions.
The most expensive in terms of performance is the detachment because it makes copies of persistent objects. The advantage of detachment is that changes made outside the transaction can be futher used to update the database in a new transaction. The other methods also allow changes outside of the transaction, but the changed instances can't be used to update the database. In RetainValues=true and makeTransient no object copies are made and the object values are set down in instances when the PersistenceManager disassociates them. Both methods are equivalent in performance, however the makeTransient method will set the values of the object during the instant the makeTransient method is invoked, and the RetainValues=true will set values of the object during commit. The bottom line is to not use detachment if instances will only be used to read values. |