Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / JavaBeans / September 2003

Tip: Looking for answers? Try searching our database.

Optimization of queries in JBoss/MySQL?

Thread view: 
Keith Simeon - 04 Sep 2003 21:05 GMT
Hello all, I've written a CMP 2.0 entity bean, with a finder method
findAll() that returns a Collection of all instances of it from the
database.  The EJB-QL associated with this query is a simple 'SELECT
Object(o) FROM table'.

When I run the findAll() method, I see the following queries in the
MySQL query log :

SELECT id FROM table;
SELECT field1, field2, field3 FROM table WHERE (id=1) OR (id=2) OR
(id=3) OR (id=4) OR (id=5) OR (id=6) OR (id=7) OR (id=8) OR (id=9) OR
(id=10) OR (id=11) ...  etc.

The second query consists of 500+ OR clauses.  Needless to say this is
horribly inefficient.  This query takes ~13 seconds to execute, where
a simple 'SELECT field1, field2, field3 FROM table' takes .02 seconds
to execute.

I've tried overriding the EJB-QL with JBOSS-QL in the
jbosscmp-jdbc.xml DD file, but had the same results.

Can anyone provide some help/suggestions/additional reading, etc?

Thanks in advance,
Keith
Marek Lange - 04 Sep 2003 22:28 GMT
Keith Simeon schrieb:
> Hello all, I've written a CMP 2.0 entity bean, with a finder method
> findAll() that returns a Collection of all instances of it from the
[quoted text clipped - 21 lines]
> Thanks in advance,
> Keith

If it is necessary to execute findAll() you can use other loading
strategies (read-ahead etc.). However, consider to narrow your sql
request if possible. FindAll() is not the best idea if lots of rows are
returned.

-marek


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.