You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by philipina <so...@hotmail.com> on 2007/04/12 14:05:44 UTC

Torque is very slow to do a .copy of an object :( Why?

Hello,
I'm using torque to connect to my Mysql database.
I'm trying to improve performence of my application and I saw that torque is
taking more than 600 ms to execute a command like:
---------------------------------------------
Object1 myCopiedObject1 = myObject1.copy();
---------------------------------------------

Torque is only slow if I have a lots of data in my DB. I cannot understand
this! a copy should only do the work in memory and not access the DB.

Why is it soo slow? Any idea to speed-up this copy?

Thanks in advance.

Alain 
-- 
View this message in context: http://www.nabble.com/Torque-is-very-slow-to-do-a-.copy-of-an-object-%3A%28-Why--tf3565099.html#a9958046
Sent from the Apache DB - Torque Users mailing list archive at Nabble.com.


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


RE: Torque is very slow to do a .copy of an object :( Why?

Posted by philipina <so...@hotmail.com>.
Thanks a lot for all of your answers. Now I understand wh I had duplicate
entries in another table ;)

I tried to use the function .copy(false) but apparently this one does not
exists (I'm using torque 3.2-rc2) :(

Alain


Greg Monroe wrote:
> 
> I remember there was a discussion a while back on the deep 
> copy stuff.  I recall that the underlying logic for making
> this the default was related to a copied object not being 
> a "true" copy (as defined by the Java specs?) unless the 
> associated complex objects were copied. But my memory's
> prone to parity errors occationally...
> 
> Anyway, if you don't care about a copy being exact to 
> the level of the related objects, you can use:
> 
> newRecord = record.copy(false); 
> 
> This will do a simpler and faster copy.  If you use the
> copy to get related objects, only then will the cache
> be refilled.
> 
> If you're code is slowing down with more data, turning 
> on logging for Torque is a good idea.  The logs will have a
> short version of all queries done and the time it took.  This
> can let you quickly find the expensive queries that you need
> to look at.  Generally, this means that you probably need 
> to add an index or two on the where clause values.
> 
>> -----Original Message-----
>> From: Federico Fissore [mailto:federico.fissore@concept.it] 
>> Sent: Thursday, April 12, 2007 10:48 AM
>> To: Apache Torque Users List
>> Subject: Re: Torque is very slow to do a .copy of an object :( Why?
>> 
>> Hidde Boonstra [Us Media] ha scritto:
>> > Hi,
>> >
>> > sorry, but I think that's what I mean:-) So if you have object1 and
>> > object2 which references to object1 and you do a copy on object1 it 
>> > will also copy and add all object2 instances that refer to 
>> object1. It 
>> > looks like this is recursive, because objects that refer to object2 
>> > will probably be copied as well...
>> >
>> > Hope this helps to explain your slowdown,
>> >
>> > Hidde.
>> >
>> 
>> You may also want to turn on debugging on package 
>> org.apache.torque and see how many and what queries are you 
>> actually doing by copying your object. You may find that 
>> number surprising.
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: torque-user-help@db.apache.org
>> 
>> 
> 
> Duke CE Privacy Statement
> Please be advised that this e-mail and any files transmitted with it are
> confidential communication or may otherwise be privileged or confidential
> and are intended solely for the individual or entity to whom they are
> addressed.  If you are not the intended recipient you may not rely on the
> contents of this email or any attachments, and we ask that you  please not
> read, copy or retransmit this communication, but reply to the sender and
> destroy the email, its contents, and all copies thereof immediately.  Any
> unauthorized dissemination, distribution or copying of this communication
> is strictly prohibited.
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Torque-is-very-slow-to-do-a-.copy-of-an-object-%3A%28-Why--tf3565099.html#a9973353
Sent from the Apache DB - Torque Users mailing list archive at Nabble.com.


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


RE: Torque is very slow to do a .copy of an object :( Why?

Posted by Greg Monroe <Gr...@DukeCE.com>.
I remember there was a discussion a while back on the deep 
copy stuff.  I recall that the underlying logic for making
this the default was related to a copied object not being 
a "true" copy (as defined by the Java specs?) unless the 
associated complex objects were copied. But my memory's
prone to parity errors occationally...

Anyway, if you don't care about a copy being exact to 
the level of the related objects, you can use:

newRecord = record.copy(false); 

This will do a simpler and faster copy.  If you use the
copy to get related objects, only then will the cache
be refilled.

If you're code is slowing down with more data, turning 
on logging for Torque is a good idea.  The logs will have a
short version of all queries done and the time it took.  This
can let you quickly find the expensive queries that you need
to look at.  Generally, this means that you probably need 
to add an index or two on the where clause values.

> -----Original Message-----
> From: Federico Fissore [mailto:federico.fissore@concept.it] 
> Sent: Thursday, April 12, 2007 10:48 AM
> To: Apache Torque Users List
> Subject: Re: Torque is very slow to do a .copy of an object :( Why?
> 
> Hidde Boonstra [Us Media] ha scritto:
> > Hi,
> >
> > sorry, but I think that's what I mean:-) So if you have object1 and
> > object2 which references to object1 and you do a copy on object1 it 
> > will also copy and add all object2 instances that refer to 
> object1. It 
> > looks like this is recursive, because objects that refer to object2 
> > will probably be copied as well...
> >
> > Hope this helps to explain your slowdown,
> >
> > Hidde.
> >
> 
> You may also want to turn on debugging on package 
> org.apache.torque and see how many and what queries are you 
> actually doing by copying your object. You may find that 
> number surprising.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
> 
> 

Duke CE Privacy Statement
Please be advised that this e-mail and any files transmitted with it are confidential communication or may otherwise be privileged or confidential and are intended solely for the individual or entity to whom they are addressed.  If you are not the intended recipient you may not rely on the contents of this email or any attachments, and we ask that you  please not read, copy or retransmit this communication, but reply to the sender and destroy the email, its contents, and all copies thereof immediately.  Any unauthorized dissemination, distribution or copying of this communication is strictly prohibited.



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


Re: Torque is very slow to do a .copy of an object :( Why?

Posted by Federico Fissore <fe...@concept.it>.
Hidde Boonstra [Us Media] ha scritto:
> Hi,
>
> sorry, but I think that's what I mean:-) So if you have object1 and
> object2 which references to object1 and you do a copy on object1 it
> will also copy and add all object2 instances that refer to object1. It
> looks like this is recursive, because objects that refer to object2
> will probably be copied as well...
>
> Hope this helps to explain your slowdown,
>
> Hidde.
>

You may also want to turn on debugging on package org.apache.torque and
see how many and what queries are you actually doing by copying your
object. You may find that number surprising.

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


Re: Torque is very slow to do a .copy of an object :( Why?

Posted by "Hidde Boonstra [Us Media]" <hi...@usmedia.nl>.
Hi,

sorry, but I think that's what I mean:-) So if you have object1 and 
object2 which references to object1 and you do a copy on object1 it will 
also copy and add all object2 instances that refer to object1. It looks 
like this is recursive, because objects that refer to object2 will 
probably be copied as well...

Hope this helps to explain your slowdown,

Hidde.

philipina wrote:
> Hi,
> 
> One other object has a reference to the object I want to copy but the object
> I want to copy has no reference (foreign key) to any other object.
> 
> Alain
> 
> 
> 
> Hidde Boonstra [Us Media]-2 wrote:
>> Hi Alain,
>>
>> does your object have many relations (foreign key constraints)? I just 
>> looked into the copy method and I see it does a deep copy, so if you 
>> have many relations, or many related entries in your database, these 
>> will all be copied into your copy. This might explain why it gets slower 
>> when there is more data...
>>
>> Greetz,
>>
>> Hidde.
>>
>> philipina wrote:
>>> Hello,
>>> I'm using torque to connect to my Mysql database.
>>> I'm trying to improve performence of my application and I saw that torque
>>> is
>>> taking more than 600 ms to execute a command like:
>>> ---------------------------------------------
>>> Object1 myCopiedObject1 = myObject1.copy();
>>> ---------------------------------------------
>>>
>>> Torque is only slow if I have a lots of data in my DB. I cannot
>>> understand
>>> this! a copy should only do the work in memory and not access the DB.
>>>
>>> Why is it soo slow? Any idea to speed-up this copy?
>>>
>>> Thanks in advance.
>>>
>>> Alain 
>> -- 
>> Us Media B.V.
>> Stadhouderskade 115
>> 1073 AX Amsterdam
>>
>> t: 020 428 68 68
>> f: 020 470 69 05
>> www.usmedia.nl
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: torque-user-help@db.apache.org
>>
>>
>>
> 

-- 
Us Media B.V.
Stadhouderskade 115
1073 AX Amsterdam

t: 020 428 68 68
f: 020 470 69 05
www.usmedia.nl

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


Re: Torque is very slow to do a .copy of an object :( Why?

Posted by philipina <so...@hotmail.com>.
Hi,

One other object has a reference to the object I want to copy but the object
I want to copy has no reference (foreign key) to any other object.

Alain



Hidde Boonstra [Us Media]-2 wrote:
> 
> Hi Alain,
> 
> does your object have many relations (foreign key constraints)? I just 
> looked into the copy method and I see it does a deep copy, so if you 
> have many relations, or many related entries in your database, these 
> will all be copied into your copy. This might explain why it gets slower 
> when there is more data...
> 
> Greetz,
> 
> Hidde.
> 
> philipina wrote:
>> Hello,
>> I'm using torque to connect to my Mysql database.
>> I'm trying to improve performence of my application and I saw that torque
>> is
>> taking more than 600 ms to execute a command like:
>> ---------------------------------------------
>> Object1 myCopiedObject1 = myObject1.copy();
>> ---------------------------------------------
>> 
>> Torque is only slow if I have a lots of data in my DB. I cannot
>> understand
>> this! a copy should only do the work in memory and not access the DB.
>> 
>> Why is it soo slow? Any idea to speed-up this copy?
>> 
>> Thanks in advance.
>> 
>> Alain 
> 
> -- 
> Us Media B.V.
> Stadhouderskade 115
> 1073 AX Amsterdam
> 
> t: 020 428 68 68
> f: 020 470 69 05
> www.usmedia.nl
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Torque-is-very-slow-to-do-a-.copy-of-an-object-%3A%28-Why--tf3565099.html#a9960722
Sent from the Apache DB - Torque Users mailing list archive at Nabble.com.


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


Re: Torque is very slow to do a .copy of an object :( Why?

Posted by "Hidde Boonstra [Us Media]" <hi...@usmedia.nl>.
Hi Alain,

does your object have many relations (foreign key constraints)? I just 
looked into the copy method and I see it does a deep copy, so if you 
have many relations, or many related entries in your database, these 
will all be copied into your copy. This might explain why it gets slower 
when there is more data...

Greetz,

Hidde.

philipina wrote:
> Hello,
> I'm using torque to connect to my Mysql database.
> I'm trying to improve performence of my application and I saw that torque is
> taking more than 600 ms to execute a command like:
> ---------------------------------------------
> Object1 myCopiedObject1 = myObject1.copy();
> ---------------------------------------------
> 
> Torque is only slow if I have a lots of data in my DB. I cannot understand
> this! a copy should only do the work in memory and not access the DB.
> 
> Why is it soo slow? Any idea to speed-up this copy?
> 
> Thanks in advance.
> 
> Alain 

-- 
Us Media B.V.
Stadhouderskade 115
1073 AX Amsterdam

t: 020 428 68 68
f: 020 470 69 05
www.usmedia.nl

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


RE: AW: Torque is very slow to do a .copy of an object :( Why?

Posted by philipina <so...@hotmail.com>.
Not sure... I can confirm that I do not have the copy(boolean) function but
torque is doing a deep copy because when I save my copied object I also get
a new entry in the table linked to the original objet.

Alain




Greg Monroe wrote:
> 
> Hmm, are you using a non-default build option of:
> 
> torque.complexObjectModel=false 
> 
> That's the only way that the copy( boolean deepcopy) method
> would not be created in your BaseRecord object.  If you are
> generating your OM layer with this set to false, then doing
> an OM object .copy() is just a simple memory to memory copy.
> And all the discusion of deepcopy isn't valid for you.
> 
>> -----Original Message-----
>> From: philipina [mailto:sono_uhr@hotmail.com] 
>> Sent: Friday, April 13, 2007 4:22 AM
>> To: torque-user@db.apache.org
>> Subject: Re: AW: Torque is very slow to do a .copy of an 
>> object :( Why?
>> 
>> 
>> I tried to use the function .copy(false) but apparently this 
>> one does not
>> exists (I'm using torque 3.2-rc2) :( 
>> 
>> Alain 
>> 
>> 
>> Thoralf Rickert wrote:
>> > 
>> > Hi!
>> > 
>> > Could you try a myObject1.copy(false) to avoid making a deepcopy.
>> > 
>> > bye
>> > Thoralf
>> > 
>> >> I'm using torque to connect to my Mysql database.
>> >> I'm trying to improve performence of my application and I saw 
>> >> that torque is taking more than 600 ms to execute a command like:
>> >> ---------------------------------------------
>> >> Object1 myCopiedObject1 = myObject1.copy();
>> >> ---------------------------------------------
>> >> 
>> >> Torque is only slow if I have a lots of data in my DB. I 
>> >> cannot understand this! a copy should only do the work in 
>> >> memory and not access the DB.
>> > 
>> > 
>> > 
>> > 
>> ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
>> > For additional commands, e-mail: torque-user-help@db.apache.org
>> > 
>> > 
>> > 
>> 
>> -- 
>> View this message in context: 
>> http://www.nabble.com/Torque-is-very-slow-to-do-a-.copy-of-an-
>> object-%3A%28-Why--tf3565099.html#a9974840
>> Sent from the Apache DB - Torque Users mailing list archive 
>> at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: torque-user-help@db.apache.org
>> 
>> 
> 
> Duke CE Privacy Statement
> Please be advised that this e-mail and any files transmitted with it are
> confidential communication or may otherwise be privileged or confidential
> and are intended solely for the individual or entity to whom they are
> addressed.  If you are not the intended recipient you may not rely on the
> contents of this email or any attachments, and we ask that you  please not
> read, copy or retransmit this communication, but reply to the sender and
> destroy the email, its contents, and all copies thereof immediately.  Any
> unauthorized dissemination, distribution or copying of this communication
> is strictly prohibited.
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Torque-is-very-slow-to-do-a-.copy-of-an-object-%3A%28-Why--tf3565099.html#a9983668
Sent from the Apache DB - Torque Users mailing list archive at Nabble.com.


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


Re: AW: Torque is very slow to do a .copy of an object :( Why?

Posted by Thomas Vandahl <tv...@apache.org>.
Greg Monroe wrote:
> That's the only way that the copy( boolean deepcopy) method
> would not be created in your BaseRecord object.  If you are
> generating your OM layer with this set to false, then doing
> an OM object .copy() is just a simple memory to memory copy.
> And all the discusion of deepcopy isn't valid for you.

This feature has been added after the 3.2 release. You should try one of
the latest release candidates such as 3.3-RC2

Bye, Thomas.


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


RE: AW: Torque is very slow to do a .copy of an object :( Why?

Posted by Greg Monroe <Gr...@DukeCE.com>.
Hmm, are you using a non-default build option of:

torque.complexObjectModel=false 

That's the only way that the copy( boolean deepcopy) method
would not be created in your BaseRecord object.  If you are
generating your OM layer with this set to false, then doing
an OM object .copy() is just a simple memory to memory copy.
And all the discusion of deepcopy isn't valid for you.

> -----Original Message-----
> From: philipina [mailto:sono_uhr@hotmail.com] 
> Sent: Friday, April 13, 2007 4:22 AM
> To: torque-user@db.apache.org
> Subject: Re: AW: Torque is very slow to do a .copy of an 
> object :( Why?
> 
> 
> I tried to use the function .copy(false) but apparently this 
> one does not
> exists (I'm using torque 3.2-rc2) :( 
> 
> Alain 
> 
> 
> Thoralf Rickert wrote:
> > 
> > Hi!
> > 
> > Could you try a myObject1.copy(false) to avoid making a deepcopy.
> > 
> > bye
> > Thoralf
> > 
> >> I'm using torque to connect to my Mysql database.
> >> I'm trying to improve performence of my application and I saw 
> >> that torque is taking more than 600 ms to execute a command like:
> >> ---------------------------------------------
> >> Object1 myCopiedObject1 = myObject1.copy();
> >> ---------------------------------------------
> >> 
> >> Torque is only slow if I have a lots of data in my DB. I 
> >> cannot understand this! a copy should only do the work in 
> >> memory and not access the DB.
> > 
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: torque-user-help@db.apache.org
> > 
> > 
> > 
> 
> -- 
> View this message in context: 
> http://www.nabble.com/Torque-is-very-slow-to-do-a-.copy-of-an-
> object-%3A%28-Why--tf3565099.html#a9974840
> Sent from the Apache DB - Torque Users mailing list archive 
> at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
> 
> 

Duke CE Privacy Statement
Please be advised that this e-mail and any files transmitted with it are confidential communication or may otherwise be privileged or confidential and are intended solely for the individual or entity to whom they are addressed.  If you are not the intended recipient you may not rely on the contents of this email or any attachments, and we ask that you  please not read, copy or retransmit this communication, but reply to the sender and destroy the email, its contents, and all copies thereof immediately.  Any unauthorized dissemination, distribution or copying of this communication is strictly prohibited.



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


Re: AW: Torque is very slow to do a .copy of an object :( Why?

Posted by philipina <so...@hotmail.com>.
I tried to use the function .copy(false) but apparently this one does not
exists (I'm using torque 3.2-rc2) :( 

Alain 


Thoralf Rickert wrote:
> 
> Hi!
> 
> Could you try a myObject1.copy(false) to avoid making a deepcopy.
> 
> bye
> Thoralf
> 
>> I'm using torque to connect to my Mysql database.
>> I'm trying to improve performence of my application and I saw 
>> that torque is taking more than 600 ms to execute a command like:
>> ---------------------------------------------
>> Object1 myCopiedObject1 = myObject1.copy();
>> ---------------------------------------------
>> 
>> Torque is only slow if I have a lots of data in my DB. I 
>> cannot understand this! a copy should only do the work in 
>> memory and not access the DB.
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Torque-is-very-slow-to-do-a-.copy-of-an-object-%3A%28-Why--tf3565099.html#a9974840
Sent from the Apache DB - Torque Users mailing list archive at Nabble.com.


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