db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Allen <...@mojavelinux.com>
Subject queries seem inefficient
Date Mon, 10 Mar 2003 23:27:29 GMT
Assume that I have the three related tables, as I included in an
earlier post.

If I were to do

 List members = MemberPeer.doSelectAll(new Criteria());
 
 Iterator i = members.iterator();
 
 while (i.hasNext())
 {
     Member member = (Member) i.next();
     System.out.println(member.getFirstName() + " " +
     member.getLastName() + " " + member.getCompany().getName());
 }

I discover in the logs that a new query on the company table is
executed for each and every member.  If I had 30 members to display,
that would be a total of 31 queries.  Ahhh, that can't be good!  How
do you make torque select the data before that fact?

Dan

-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Daniel Allen, <dan@mojavelinux.com>
http://www.mojavelinux.com/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
"The package said 'Windows 95 or better', so I installed Linux"
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

Mime
View raw message