I have an application which is running slowly over a WAN - we think the cause is multiple inserts into a table. I'm currently looking into more efficient ways to insert multiple rows at the same time.
I found this method:
INSERT ALL
INTO MULTI_INSERT(VAL_1, VAL_2) VALUES (100,20)
INTO MULTI_INSERT(VAL_1, VAL_2) VALUES (21,2)
INTO MULTI_INSERT(VAL_1, VAL_2) VALUES (321,10)
INTO MULTI_INSERT(VAL_1, VAL_2) VALUES (22,13)
INTO MULTI_INSERT(VAL_1, VAL_2) VALUES (14,121)
INTO MULTI_INSERT(VAL_1, VAL_2) VALUES (11,112)
INTO MULTI_INSERT(VAL_1, VAL_2) VALUES (112,23)
INTO MULTI_INSERT(VAL_1, VAL_2) VALUES (132,2323)
INTO MULTI_INSERT(VAL_1, VAL_2) VALUES (121,34)
INTO MULTI_INSERT(VAL_1, VAL_2) VALUES (24333,333)
INTO MULTI_INSERT(VAL_1, VAL_2) VALUES (1232,3434)
INTO MULTI_INSERT(VAL_1, VAL_2) VALUES (4554,3434)
INTO MULTI_INSERT(VAL_1, VAL_2) VALUES (3434,211)
INTO MULTI_INSERT(VAL_1, VAL_2) VALUES (3434,1233)
INTO MULTI_INSERT(VAL_1, VAL_2) VALUES (12,22)
INTO MULTI_INSERT(VAL_1, VAL_2) VALUES (356,233)
INTO MULTI_INSERT(VAL_1, VAL_2) VALUES (9347,23)
INTO MULTI_INSERT(VAL_1, VAL_2) VALUES (8904,245)
INTO MULTI_INSERT(VAL_1, VAL_2) VALUES (342,4545)
INTO MULTI_INSERT(VAL_1, VAL_2) VALUES (453,233)
SELECT 1 FROM DUAL;
What I would like to know is: is the method above actually more efficient than just doing 20 "INSERT INTO MY_TABLE (1,1);"? Are there other methods of doing this?
Oracle doesnt support multi rows insert, please use the next option:
insert into method (name) values ('GET'); insert into method (name) values ('POST');
You can try direct path insert to speed up operation, but for 100 records conventional path insert must be fast enough and it seems that the problem is about table locking while inserting into log from a big number of sources.
To instruct Oracle to use direct path insert you must specifiy either APPEND or APPEND_VALUES hints depending on insert statement syntax. E.g.
If insert statement originated from PL/SQL code then you can use bulk insert with forall statement to improve performance (SQLFiddle) :
Some RDBMS like mysql and now SQL Server supports multiple rows insert data syntax:
( More details in Inserting multiple rows of data of Sql Server or inserting multirow on mysql )
But don't oracle. Sorry about bad news. The more close way is documented on Tech on the Net.
Okay, so now we're getting somewhere. If you have a set-up in which your hundred statements are individual calls they will probably be sent in separate packets. That would be painful across a WAN compared to a LAN. In that case, it would be worthwhile seeing whether converting statements from RBAR to something Set-based would reduce the number of transmitted packets.
However, I would still advise you to get some hard facts before you roll-out the change. Doesn't your client have a network admin you could talk to? Or at least could you get them to install Wireshark and send you some reports?