how can i reduce the number of sql commands?

Posts   
 
    
Stranger
User
Posts: 23
Joined: 22-Nov-2005
# Posted on: 22-Nov-2005 22:30:43   

I want to save many entities that are in a graph related to each other. Suppose the root entity is ROOT.

The DB is not on local machine. it is im[portamt for me to reduce the numebr of sql command. When I use Save(ROOT), the sql profiler show many sql script. and it is very slow! I do it in a transaction too!

Is there something in LLBLGen (like VIEW in fetching) that reduce the number of SQL command.

I saw somewhere a sql command like "INSERT INTO ALL ...". does LLBLGEn support this? if not, is there a solution?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 22-Nov-2005 23:35:02   

If you want to insert 1000 rows into a table, in sqlserver, you have to execute 1000 insert statements, OR use INSERT INTO table SELECT ... . As the data comes from the entities, you're bound to the 1000 insert statements. What exactly would you have liked llblgen pro did instead of what it does now? Could you describe that in more detail, please?

Frans Bouma | Lead developer LLBLGen Pro
Stranger
User
Posts: 23
Joined: 22-Nov-2005
# Posted on: 22-Nov-2005 23:48:07   

I mean insertion to multiple tables in a single shot! is it possible?

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 23-Nov-2005 02:26:59   

I don't believe there is a syntax to do that. Could you give an example query that you are trying to reproduce?

Stranger
User
Posts: 23
Joined: 22-Nov-2005
# Posted on: 23-Nov-2005 08:49:02   

Thanks All...

I saw somewhere a sql command like this :

INSERT INTO ALL x(...) values(...) y(...) values(...) ...

but i think this is not implemented in LLBLGEN.

see this : http://www.oracle-base.com/articles/9i/SQLNewFeatures9i.php

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 23-Nov-2005 10:46:43   

array parameters for doing this aren't supported, it's a native Oracle feature and because the code ordering the production of the queries is generic code it can't utilize it. Also is it pretty limited in general. It works for bulk inserts like inserts of data imported from a resource, but for general usage it's somewhat limited due to the fact that it requires that all inserts are the same (just different values), which isn't the case in inserts in an O/R mapper where some inserts have fields ABC set, others don't.

Frans Bouma | Lead developer LLBLGen Pro
Stranger
User
Posts: 23
Joined: 22-Nov-2005
# Posted on: 23-Nov-2005 16:01:16   

ok thanks again

Lets explain the problem:

Suppose we have a tree of entities related to each other with root of ROOT. we want o save this ROOT (with related entities) about 1000 times. My DB is not on a local machine too. what is the fastest solution.

I want to send miminim SLQ command over the network.
Let me explain if it is not clear!

Paul.Lewis
User
Posts: 147
Joined: 22-Aug-2005
# Posted on: 24-Nov-2005 04:17:06   

Here's one suggestion:

Use a stored procedure.

Convert the root entity and related entities to XML and pass as a parameter into the procedure.

Inside the procedure read the XML and use it in your insert statement.

1 DB call.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 24-Nov-2005 10:09:46   

I indeed think that if you just want to limit the # of calls, a proc is all you have. Though I also think that the real slowness is from the transaction, not the 1000 insert statements.

Frans Bouma | Lead developer LLBLGen Pro