﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>CapableObjects Forums / ECO / General discussions  / deleting an object with many references / Latest Posts</title><generator>InstantForum.NET v4.1.4</generator><description>CapableObjects Forums</description><link>http://www.capableobjects.com/apps/InstantForum414/</link><webMaster>forums@capableobjects.com</webMaster><lastBuildDate>Wed, 08 Feb 2012 22:54:16 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: deleting an object with many references</title><link>http://www.capableobjects.com/apps/InstantForum414/Topic1203-4-1.aspx</link><description>A----B----C&lt;br&gt;&lt;br&gt;If you delete A then all B must be loaded so that ECO can also load all C relating to all B.&lt;br&gt;&lt;br&gt;The fact that you are clearing the association is irrelevant, the important part of your code is SomeObject.SomeAssociation.Count, which loads in the objects in order to tell you how many are in the collection.  I suspect all you are doing is loading the objects elsewhere and then noticing how much faster the delete is, or are you timing all of this code?</description><pubDate>Sat, 29 Nov 2008 17:18:39 GMT</pubDate><dc:creator>Peter Morris</dc:creator></item><item><title>RE: deleting an object with many references</title><link>http://www.capableobjects.com/apps/InstantForum414/Topic1203-4-1.aspx</link><description>Many of the associations are composite and link to other classes. Indeed, if there [b]WERE[/b] objects in those associations it could take longer time to delete. But the associations are empty, and deletion takes long time anyway, while clearing [b]EMPTY[/b] associations speeds it up a lot. I know very well that this is strange and looks like a shaman thing, though it does behave this way.&lt;br&gt;&lt;br&gt;Best regards,&lt;br&gt;Dmitry</description><pubDate>Fri, 28 Nov 2008 16:11:41 GMT</pubDate><dc:creator>Dmitry</dc:creator></item><item><title>RE: deleting an object with many references</title><link>http://www.capableobjects.com/apps/InstantForum414/Topic1203-4-1.aspx</link><description>&amp;gt; if (anObject.AssociationX.Count==0) anObject.AssociationX.Clear();&lt;/P&gt;&lt;P&gt;&lt;BR&gt;I'm sure it is nothing to do at all in this case:)</description><pubDate>Fri, 28 Nov 2008 15:43:27 GMT</pubDate><dc:creator>efim</dc:creator></item><item><title>RE: deleting an object with many references</title><link>http://www.capableobjects.com/apps/InstantForum414/Topic1203-4-1.aspx</link><description>Clearing the associations will merely unlink the objects.  If the association is 1..* then it will load in the child objects anyway, but if it is *..* it will only load in the link objects.&lt;br&gt;&lt;br&gt;I think the difference however comes in that when you delete with links ECO has to check each of the child objects to see if those are permitted to be deleted too (if you have cascade delete, or they are composite).  Which in turn could mean that each of those objects then load up their composite objects to see if they are permitted to be deleted, and so on.&lt;br&gt;&lt;br&gt;Is your association composite.  Do the child objects also have composite associations of their own?&lt;br&gt;&lt;br&gt;&lt;br&gt;Pete</description><pubDate>Fri, 28 Nov 2008 14:57:26 GMT</pubDate><dc:creator>Peter Morris</dc:creator></item><item><title>RE: deleting an object with many references</title><link>http://www.capableobjects.com/apps/InstantForum414/Topic1203-4-1.aspx</link><description>No, I can't tell why this improves the speed. but it sounds like there is either a bug, or room for optimizations here... Could you check with the EcoSpaceDebugger if there is any difference in which SQL statements are executed when you clear before or not?</description><pubDate>Fri, 28 Nov 2008 11:32:02 GMT</pubDate><dc:creator>Jonas Hogstrom</dc:creator></item><item><title>deleting an object with many references</title><link>http://www.capableobjects.com/apps/InstantForum414/Topic1203-4-1.aspx</link><description>Hello!&lt;br&gt;&lt;br&gt;I have a class which references many other classes as 1:n and n:m. When I execute anObject.AsIObject().Delete(), it may take up to a second (!) to delete a single instance. But, if I go over all its associations and do something like this:&lt;br&gt;if (anObject.AssociationX.Count==0) anObject.AssociationX.Clear();&lt;br&gt;it gets deleted blazing fast.&lt;br&gt;&lt;br&gt;Does anyone have an idea why clearing empty associations makes deletion to execute with a normal speed, while without it it is very slow? The database presently has about 800'000 records in all tables.&lt;br&gt;&lt;br&gt;Take care,&lt;br&gt;Dmitry</description><pubDate>Fri, 28 Nov 2008 06:22:15 GMT</pubDate><dc:creator>Dmitry</dc:creator></item></channel></rss>
