Forgot to copy the list before, gist was use SQL*Join instead, so that it uses
a SelectResults instance. That's also the answer here: you can then use
.count, .filter, .sum, etc on the join property.
j.transactions.count()
Quoting Michael Gauckler <[EMAIL PROTECTED]>:
> Hi,
>
> thank your for the reply to me previous posting. Using SQLMultipleJoin
> (instead of MultipleJoin) speeds things up dramatically.
>
> Again a question on a similar issue: I need to count the elements. I would
> like to do this fast and elegant.
>
> class Job(sqlobject.SQLObject):
> name = sqlobject.StringCol()
> ...
> transactions = sqlobject.SQLMultipleJoin('Transaction')
>
> To count the transactions of a job I can do:
>
> 1)
> numtrs = Transaction.select(Job.q.id==int(id)).count()
> (SQL'ish, This lets the DB do the counting)
>
> 2)
> numtrs = len([a.id for a in page.job.transactions])
> (Pythonic, This loads all data and counts it)
>
> Where 1) is fast and 2) is elegant. Is there a fast and elegant way?
>
> Thanks again for suggestions.
>
> Regards,
> Michael Gauckler
>
>
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss