[OJB-developers] OQLQueryImpl effieciency
Brought to you by:
thma
From: Charles A. <cha...@hp...> - 2001-11-01 16:46:55
|
Hi all, Whilst using OJB in a prototype, I found that using the standard ojb.odmg.oql.OQLQueryImpl class to do an OQL query seemed a little inefficient. It turns out that this is because OQLQueryImpl uses a DList to return the results as a collection. The DList implementation access the OJB_SEQ table to gain an ID for itself, and one for each entry in the list. I have attached a quick-n-dirty try to improve on this; basically, I've implemented a ManageableArrayList collection, which extends ArrayList and implements ManageableCollection. I've also implemented a SpeedyQuery class, which extends OQLQueryImpl and overrides execute to return a ManageableArrayList instead of a DList. I've also attached a simple CompareQueries class that tests the SpeedyQuery class. In this test (against a table with 1889 rows on SQL server), the OQLQueryImpl took on average 37 secs. The SpeedyQuery took 1.5 secs. I'm sure there are drawbacks to this approach, and I'm sure that I've overlooked something terribly important. The only things that I note at the moment are : * I'm not currently registering the resulting items with the current transaction; this would be trivial to achieve. * If you remove or add an item to the ManageableArraylist, the changes would not be propogated to the database. Still, even with those caveats (which I'm sure are possible to deal with), I still think this speed improvement is not to be sniffed at. Comments are welcome; just be gentle with me - this is the first code I have sent to an open-source mailing list.... With thanks, Charles. This email and any attachments are strictly confidential and are intended solely for the addressee. If you are not the intended recipient you must not disclose, forward, copy or take any action in reliance on this message or its attachments. If you have received this email in error please notify the sender as soon as possible and delete it from your computer systems. Any views or opinions presented are solely those of the author and do not necessarily reflect those of HPD Software Limited or its affiliates. At present the integrity of email across the internet cannot be guaranteed and messages sent via this medium are potentially at risk. All liability is excluded to the extent permitted by law for any claims arising as a re- sult of the use of this medium to transmit information by or to HPD Software Limited or its affiliates. |