Which is faster -- DeleteEntity, DeleteEntitiesDirectly, or DeleteEntityCollection

Posts   
 
    
mkamoski avatar
mkamoski
User
Posts: 116
Joined: 06-Dec-2005
# Posted on: 13-Jul-2006 20:11:23   

All --

Assuming that there is one only entity to be deleted...

Which is faster -- DeleteEntity, DeleteEntitiesDirectly, or DeleteEntityCollection?

Is there any significant difference?

Please advise.

(FYI, we are using LLBLGen, ASP.NET, VS.NET 2003, VB.NET, .NET 1.1, the Adapter templates, SQL Server 2000, web services, SD.LLBLGen.Pro.DQE.SqlServer.NET11.dll Version 1.0.20051.60516, SD.LLBLGen.Pro.ORMSupportClasses.NET11.dll Version 1.0.20051.60628, Windows XP Pro, IIS 5.1, and so on.)

Thank you.

-- Mark Kamoski

hlesesne avatar
hlesesne
User
Posts: 47
Joined: 22-Jul-2004
# Posted on: 14-Jul-2006 04:06:55   

My assumption would be that it all depends...

DeleteEntity will delete on key and DeleteEntityCollection will delete on each key in the collection (separately). If there were multiple entities in the collection, it would then be slower as it would make a separate db call for each entity.

If you were to do a DeleteEntitiesDirectly with you predicate containing only the primary key, then I would assume it to be the same speed as the other two.

However, if using a complex predicate on multiple entities then DeleteEntitiesDirectly would be faster than DeleteEntityCollection as it would require only a single call to the database.

Whew. Please, someone correct me if I am mistaken.

Posts: 1251
Joined: 10-Mar-2006
# Posted on: 14-Jul-2006 04:38:27   

Real question is what SQL is generated for each of these.

Easy to test - setup a test with all 3 deletes and turn diagnostic messages on. Run in debug mode, look at the SQL that is generated in the output window.

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 14-Jul-2006 08:32:57   

The same speed for the three of them. (Since you are only deleting one entity)