Indeed, just one query should be enough reducing the
extra database trip. Even a dynamically created
query(of course optimized), will be faster then two
database trips (even if the database trips were using
stored procs.)
You can dynamically join whatever you want, and the
data coming back unless they are blobs or clobs or
raws
is not going to exceed the bandwidth.
Like an IN query as Robert says would definitely work
and anything else joined together.
Still can apply the rules of optimization ofcourse.
--- Robert Nicholson <[EMAIL PROTECTED]> wrote:
> If you have the keys why not just build an IN clause
> type query?
>
> > -----Original Message-----
> > From:
> [EMAIL PROTECTED]
> >
>
[mailto:[EMAIL PROTECTED]]On
> Behalf Of Jay
> > Walters
> > Sent: Monday, May 07, 2001 6:49 PM
> > To: 'Filip Hanik ';
> '[EMAIL PROTECTED] '
> > Subject: RE: [JBoss-dev] TODO: JBossCMP 1.1 FAST!
> >
> >
> > Why not just one query?
> >
> > -----Original Message-----
> > From: Filip Hanik
> > To: [EMAIL PROTECTED]
> > Sent: 5/7/01 9:39 PM
> > Subject: RE: [JBoss-dev] TODO: JBossCMP 1.1 FAST!
> >
> > > Sorry lets put that in context, need to
> eliminate N+1 query problem
> > first.
> > > Reduce trips to the database is #1. Then make
> the trips more
> > efficient.
> >
> > yes, 2 queries should be enough assuming that one
> bean's data can be
> > contained within one row.
> >
> > query 1: is the finder query that returns the
> primary key objects.
> > query 2: is the retrieve query that returns the
> data for the actual
> > entity
> > beans.
> >
> > if query 2 is constructed in such a way that
> > a) select ...all data that needs to be
> collected... from table
> > b) where ...same where clause as the find
> query...AND (additional joins
> > if
> > needed)
> >
> > as you can see. since query 1 and query 2 should
> have similar where
> > clauses,
> > there is no need to execute "select ...data...
> from table where key = ?"
> > N
> > number of times.
> >
> > does this makes sense to you, so in this case each
> findXXX:Collection
> > would
> > only require two queries.
> >
> >
> > Filip
> >
> > ~
> > Namaste - I bow to the divine in you
> > ~
> > Filip Hanik
> > Software Architect
> > [EMAIL PROTECTED]
> > www.filip.net
> >
> >
> > _______________________________________________
> > Jboss-development mailing list
> > [EMAIL PROTECTED]
> >
>
http://lists.sourceforge.net/lists/listinfo/jboss-development
> >
> > _______________________________________________
> > Jboss-development mailing list
> > [EMAIL PROTECTED]
> >
>
http://lists.sourceforge.net/lists/listinfo/jboss-development
> >
>
> _______________________________________________
> Jboss-development mailing list
> [EMAIL PROTECTED]
>
http://lists.sourceforge.net/lists/listinfo/jboss-development
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development