You will get better performance if you constrain the initial query,
especially if there are many dogs:

rows=db(db.person.id==db.dog.owner,db.dog.kind=='mutt').select()
or
rows=db(db.person.id==db.dog.owner).select(limitby=100)

Since batch get returns the people list in the order that you sent it
dog.owners,
orderby will be preserved, as long as orderby is on the dogs table:

rows=db(db.person.id==db.dog.owner).select(orderby=db.dog.age)

I have not tried any of this yet, but I do not see why it would not
work.

Robin


On Feb 1, 1:35 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
> I'll wait for your patch. ;-)
>
> Massimo
>
> On Feb 1, 1:22 pm, Robin B <robi...@gmail.com> wrote:
>
> > To accomplish this:
> > rows=db(db.person.id==db.dog.owner).select()
>
> > In the driver do this:
> > do a query:
> >  dogs=db(db.dogs.id>0).select()
> > do a batch get:
> >  people = db.people([dog.owner for dog in dogs])
>
> > merge the 2 lists and return SQLRows.
>
> > Robin
>
> > On Feb 1, 1:16 pm, billf <billferr...@blueyonder.co.uk> wrote:
>
> > > I would like to see how this code looks as well please
>
> > > On Feb 1, 5:48 pm, Robin B <robi...@gmail.com> wrote:
>
> > > > This should work for left joins too because batch get returns None
> > > > when an id does not exist.
>
> > > >http://code.google.com/appengine/docs/python/datastore/functions.html
>
> > > > 1000 results/query, 30 queries/request = 30,000 results/request max
> > > > using queries
>
> > > > I have not seen a limit for results/batch_get so using batch get could
> > > > allow ++30,000 results/request
>
> > > > You have to process everything in under 10 sec else your HTTP request
> > > > will time out.
>
> > > > GAE will be announcing cron very soon, so long running tasks will be
> > > > here shortly.
>
> > > > Robin
>
> > > > On Feb 1, 11:29 am, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > > > Can you send me a patch! this would be great!
>
> > > > > On Feb 1, 10:58 am, Robin B <robi...@gmail.com> wrote:
>
> > > > > > This is an example from the web2py book:
>
> > > > > > 1 >>> rows=db(db.person.id==db.dog.owner).select()
> > > > > > 2 >>> for row in rows: print row.person.name, 'has', row.dog.name
> > > > > > 3 Alex has Skipper
> > > > > > 4 Alex has Snoopy
> > > > > > 5 Bob has Puppy
>
> > > > > > This 1 level inner join will be able to be performed on GAE
> > > > > > efficiently using batch get, so long as you are joining on a primary
> > > > > > key (id).
>
> > > > > > Joins on GAE!
>
> > > > > > Robin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to