It batches based on the statement. So given this example:
INSERT INTO author (id,username, password, email, bio) VALUES (1,'jim','********','[EMAIL PROTECTED]',''); INSERT INTO author (id,username, password, email, bio) VALUES (2,'sally','********','[EMAIL PROTECTED]',null); INSERT INTO blog (id,author_id,title) VALUES (1,1,'Jim Business'); INSERT INTO blog (id,author_id,title) VALUES (2,2,'Bally Slog'); INSERT INTO post (id,blog_id,created_on,subject,body) VALUES (1,1,'2007-12-05-00.00.00','Corn nuts','I think if I never smelled another corn nut, it would be too soon...'); INSERT INTO post (id,blog_id,created_on,subject,body) VALUES (2,1,'2008-01-12-00.00.00','Paul Hogan on Toy Dogs','That''s not a dog. THAT''s a dog!'); INSERT INTO post (id,blog_id,created_on,subject,body) VALUES (3,2,'2007-12-05-00.00.00','Monster Trucks','I think monster trucks are great...'); INSERT INTO post (id,blog_id,created_on,subject,body) VALUES (4,2,'2008-01-12-00.00.00','Tea Parties','A tea party is no place to hold a business meeting...'); These would be executed with 3 batches. If you mix up the order... INSERT INTO author (id,username, password, email, bio) VALUES (1,'jim','********','[EMAIL PROTECTED]',''); INSERT INTO blog (id,author_id,title) VALUES (1,1,'Jim Business'); INSERT INTO post (id,blog_id,created_on,subject,body) VALUES (1,1,'2007-12-05-00.00.00','Corn nuts','I think if I never smelled another corn nut, it would be too soon...'); INSERT INTO post (id,blog_id,created_on,subject,body) VALUES (2,1,'2008-01-12-00.00.00','Paul Hogan on Toy Dogs','That''s not a dog. THAT''s a dog!'); INSERT INTO author (id,username, password, email, bio) VALUES (2,'sally','********','[EMAIL PROTECTED]',null); INSERT INTO blog (id,author_id,title) VALUES (2,2,'Bally Slog'); INSERT INTO post (id,blog_id,created_on,subject,body) VALUES (3,2,'2007-12-05-00.00.00','Monster Trucks','I think monster trucks are great...'); INSERT INTO post (id,blog_id,created_on,subject,body) VALUES (4,2,'2008-01-12-00.00.00','Tea Parties','A tea party is no place to hold a business meeting...'); It would execute with 6 batches. Doing it any other way would cause the statements to execute out of order, which is a more serious concern and not correctable by the user of the framework. Clinton From: Chris McMahon [mailto:[EMAIL PROTECTED] Sent: February-29-08 11:43 AM To: [email protected] Subject: RE: iBATIS and Batch We use the batch functionality frequently. How is iBATIS determining what is homogeneous and what is heterogeneous? We have a mix of both straight SQL updates and prepared statement updates. _____ From: [EMAIL PROTECTED] To: [email protected] Subject: RE: iBATIS and Batch Date: Fri, 29 Feb 2008 08:58:43 -0700 Unfortunately no... that's possibly something we can consider for future versions. The challenge is that some people have the exact opposite problem. They need the statements to maintain the order of execution. When initially deciding who to help, I decided that preserving the order of execution was more important than performance. I also assumed that if you're using a mixed order of heterogeneous statements, you could probably find a way to order them by type and send them through to make the most of batching. Whereas the opposite wouldn't be true, as if I always just reordered the statements for the sake of performance - there would be no way back. I suppose we could support it as an option, but before that I have to ask: Can you reorder your statements? If not, why not? Clinton From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: February-29-08 8:47 AM To: [email protected] Subject: iBATIS and Batch Recently we have been implementing batched SQL calls using iBatis through JDBC. IT appears that iBatis will reorganize batch statements into homogenous calls and treat them as separate batches.... The problem is that is if you do not serially add the homogenous statements, each 'change' from homogeneity results in a separate batch... Does this sound correct? Is there something we can do to control the batching of heterogeneous calls? Thank you, Christopher _____ Connect and share in new ways with Windows Live. Get it now! <http://www.windowslive.com/share.html?ocid=TXT_TAGHM_Wave2_sharelife_012008 >
