Bad load time (20 objects/sec)
sseaman Oct 7, 2002 5:35 PMI have a Bean (local/remote) named School that has a relationship to few other beans.
If I use a finder to get an iteration of the Beans it takes less than one second but when I go over the beans and use two or three get()'s from the bean I drop down to processing 20 beans a second.
This is very slow and I'm wondering if there are ways to improve the performance.
Here is the code that is doing the lookup (it is in a jsp file for right now):
SchoolHome slh = (SchoolHome)ctx.lookup(EJBConstants.JNDI.SCHOOL);
Iterator it = slh.findByState(user.getLeagueContact().getState().getStateId()).iterator();
Vector schoolsInLeague = new Vector();
int maxLen = 0;
StringBuffer options = new StringBuffer();
// This loop only does 20 beans a second...
while (it.hasNext()) {
School sc = (School)it.next();
if ( (sc.getLeague() == null) || (sc.getLeague().getLeagueId() != leagueId) ) {
String scName = sc.getName();
int scNameLen = scName.length();
if (scNameLen > maxLen) maxLen = scNameLen;
options.append("<OPTION value=\"").append(sc.getSchoolId()).append("\">")
.append(scName).append("\n");
}
else {
schoolsInLeague.addElement(sc);
}
}
Now, what I have found very odd is the SQL that is being created by JBoss. Here is a snipit:
2002-10-07 16:44:49,841 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.School] Executing SQL: SELECT schoolId,name, address1, address2, city, postalCode, url, state, league FROM School WHERE (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?) OR (schoolId=?)
And it does this for EACH bean but everytime the number of (schoolId=?) decreases by one.
I'm curious why it is doing it and even it if has to, why doesn't it just use an IN()?
Any help on speeding this up would be great. Right now it takes over 6 seconds to render the page...
Thanks!