db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Josh Holtzman <j...@joshholtzman.com>
Subject Re: Performance problems
Date Thu, 27 Nov 2003 08:21:36 GMT
Thanks Andras.  I thought about doing joins, but I run into this 
problem:  Not all accounts have an assignment.  I still want to show the 
accounts with no assignments, and the join keeps any account without an 
assignment out of the results.  I will look into creating a view, but 
I'm not sure how I can create a torque object that maps to a view rather 
than a table.  Are there any references for how to do this?

Thanks again for your help!
Josh

Andras Balogh wrote:

>    Hello Josh,
>
>    What happens is the torque loads each object (if its doesn't have 
> it already ) from the DB.
> You should try to use the methods doSelectJoin .... to tell torque 
> that make a join in the tables
> and load all objects form one shoot, or i think better is to make your 
> own method
> doSelectAccountJoinByJobsJoinByCategory :).
>    Another way would be to create a view in your DB that contains all 
> info you need to display and generate for that aslo
> torque classes. This will work olny if you read the info only (i.e. a 
> report on screen or something like that)
> but not making modfications (insert/update/delete) beacause i don't 
> know how these works on views.
>
> Best wishes,
> Andras.
>
>
>
> Josh Holtzman wrote:
>
>> I'm using torque in a webapp, and I'm seeing really slow performance 
>> when I try to get data from "nested" objects.  Here's what I mean:
>>
>> I have a torque object named Account.  An account can have several 
>> Assignments, which is another torque object.  An assignment can have 
>> Jobs (yup -- another torque object) and a Job can have a Category 
>> (yet another torque object).  Due to the amount of data stored in 
>> each of these, they must be separate objects (I'm trying to avoid 
>> eliciting the obvious solution "put all of that info in one object" 
>> suggestion).
>>
>> I grab a list of accounts in my servlet with a doSelect(criteria) and 
>> send them to a JSP to be displayed (I'm using struts, but that's 
>> beside the point).  If I ask the JSP to just display info in the 
>> Account object, everything runs quickly.  If I ask the JSP to get the 
>> Account's Assignments and display info from the Assignments, it slows 
>> down a bit.  Once I ask for Job or category info, it grinds to a crawl.
>>
>> I'm wondering what's going on when I ask the JSP to 
>> account.getAssignments().  Is the JSP hitting the database in order 
>> to instantiate the account's assignments?  I would think that when I 
>> instantiated the Account, all of its own internal objects (the 
>> assignments, the jobs, the categories) would also be instantiated.  
>> So why then the huge performance hit?
>>
>> I know that I am missing something here, so please, all of you Torque 
>> gurus, let me know where young grasshopper has strayed from the 
>> path.  And if I need to provide more details (code, etc), I can do 
>> that too.
>>
>> Thanks so much,
>> Josh
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: torque-user-help@db.apache.org
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message