which one is faster?

Posts   
 
    
Stranger
User
Posts: 23
Joined: 22-Nov-2005
# Posted on: 28-Nov-2005 23:32:28   

Hi

I am curious what is the difference between saving a graph of entities and saving each enitity in graph.

for example if we have N entities, they can be saved as this :

//start transaction SaveEntitiy(entity1) ... SaveEntitiy(entityN) //commit transaction

or they can be grouped together in a graph of entities with root of ROOT and then saved as this :

//start transaction SaveEntity(Root) //commit transaction

What is the difference? which one is faster?

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 29-Nov-2005 02:38:25   

//start transaction SaveEntity(Root) //commit transaction Would be the way that I would go. The entities keep track of whether or not they are dirty and need to be saved, which may cut down on your calls to your database right there.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 29-Nov-2005 06:43:23   

Like Paul said, better to save them as a graph with a call to save the root enity. I would add that this save internally starts a transaction, so you wouldn't need to start your own.