How OJB compares to native JDBC programming
important note: this document is not finished yet.
introduction
"There is nothing like a free lunch."
(North American proverb)
Object/relational mapping tools hide the details of relational
databases from the application developer. The developer can
concentrate on implementing business logic and is liberated from
caring about RDBMS related coding with JDBC and SQL.
O/R mapping tools allow to separate business logic from RDBMS
access by forming an additional software layer between business logic
and RDBMS. Introducing new software layers always eats up additional
computing resources.
In short: the price for using O/R tools is
performance.
Software architects have to take in account this tradeoff between
programming comfort and performance to decide if it is appropiate to
use an O/R tool for a specific software system.
This document describes the OJB Performance TestSuite. This
TestSuite allows to compare OJB against native JDBC programming
against your RDBMS of choice.
Interpreting the result of these benchmarks carefully will help to
decide whether using OJB is viable for specific application scenarios
or if native JDBC programming should be used for performance reasons.
The Performance TestSuite
The OJB Performance TestSuite consist of two JUnit Testcases. The
TestCase test.ojb.broker.PerformanceTest
contains the OJB based test. And The TestCase
test.ojb.broker.PerformanceJdbcReferenceTest
contains the JDBC based tests.
the Test scenarios
inserting objects
updating objects
retrieving objects by primary key based lookup
perform last test again to test caching behaviour
fetch objects from a cursor
deleting objects
running the test suite
The TestSuite is integrated into the OJB build mechanism. You can
invoke it by typing
build[.sh]
performance.
If running OJB out of the box the tests will be performed against
the Hypersonic SQL shipped with OJB. A typical output looks like
follows:
performance:
[ojb] [BOOT] INFO: OJB.properties: file:/home/tom/ojb-1-0/build/test/ojb/OJB.properties
[ojb] .[performance] INFO:
[ojb] [performance] INFO: inserting 10000 Objects: 6374 msec
[ojb] [performance] INFO: updating 10000 Objects: 6083 msec
[ojb] [performance] INFO: querying 10000 Objects: 2878 msec
[ojb] [performance] INFO: querying 10000 Objects: 171 msec
[ojb] [performance] INFO: fetching 10000 Objects: 514 msec
[ojb] [performance] INFO: deleting 10000 Objects: 2126 msec
[ojb] [performance] INFO:
[ojb] [performance] INFO: inserting 10000 Objects: 4479 msec
[ojb] [performance] INFO: updating 10000 Objects: 7232 msec
[ojb] [performance] INFO: querying 10000 Objects: 2918 msec
[ojb] [performance] INFO: querying 10000 Objects: 153 msec
[ojb] [performance] INFO: fetching 10000 Objects: 853 msec
[ojb] [performance] INFO: deleting 10000 Objects: 1968 msec
[ojb] [performance] INFO:
[ojb] [performance] INFO: inserting 10000 Objects: 5601 msec
[ojb] [performance] INFO: updating 10000 Objects: 6471 msec
[ojb] [performance] INFO: querying 10000 Objects: 2682 msec
[ojb] [performance] INFO: querying 10000 Objects: 151 msec
[ojb] [performance] INFO: fetching 10000 Objects: 678 msec
[ojb] [performance] INFO: deleting 10000 Objects: 1956 msec
[ojb]
[ojb] Time: 54,151
[ojb]
[ojb] OK (1 tests)
[ojb]
[jdbc] [BOOT] INFO: OJB.properties: file:/home/tom/ojb-1-0/build/test/ojb/OJB.properties
[jdbc] .[performance] INFO:
[jdbc] [performance] INFO: inserting 10000 Objects: 2494 msec
[jdbc] [performance] INFO: updating 10000 Objects: 3229 msec
[jdbc] [performance] INFO: querying 10000 Objects: 2129 msec
[jdbc] [performance] INFO: querying 10000 Objects: 1905 msec
[jdbc] [performance] INFO: fetching 10000 Objects: 116 msec
[jdbc] [performance] INFO: deleting 10000 Objects: 927 msec
[jdbc] [performance] INFO:
[jdbc] [performance] INFO: inserting 10000 Objects: 2435 msec
[jdbc] [performance] INFO: updating 10000 Objects: 3224 msec
[jdbc] [performance] INFO: querying 10000 Objects: 1906 msec
[jdbc] [performance] INFO: querying 10000 Objects: 1911 msec
[jdbc] [performance] INFO: fetching 10000 Objects: 126 msec
[jdbc] [performance] INFO: deleting 10000 Objects: 909 msec
[jdbc] [performance] INFO:
[jdbc] [performance] INFO: inserting 10000 Objects: 2482 msec
[jdbc] [performance] INFO: updating 10000 Objects: 3603 msec
[jdbc] [performance] INFO: querying 10000 Objects: 2091 msec
[jdbc] [performance] INFO: querying 10000 Objects: 2335 msec
[jdbc] [performance] INFO: fetching 10000 Objects: 271 msec
[jdbc] [performance] INFO: deleting 10000 Objects: 1046 msec
[jdbc]
[jdbc] Time: 50,568
[jdbc]
[jdbc] OK (1 tests)
[jdbc]
BUILD SUCCESSFUL
By changing the JdbcConnectionDescriptor in the repository.xml file
you can point to your specific RDBMS. Please
refer to this document for details.
Interpreting test results
using OJB to write clean JDBC code