• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

BEGIN/END in mysql what it does internally on DB side

 
abhinas raj
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

i searched in google but could not find any appropriate answer for this. in mysql we use mostly in Stored procedure

BEGIN;

some sql staements

END;


so my question is that what it does internally on DB side.
 
Knute Snortum
Bartender
Pie
Posts: 2908
62
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what you mean by "what it does internally". BEGIN/END is a syntax to create a compound statement. It doesn't "do" anything.
 
abhinas raj
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:I'm not sure what you mean by "what it does internally". BEGIN/END is a syntax to create a compound statement. It doesn't "do" anything.



when is used "BEGIN" in my code then it made insertion 10 times faster. you can see the post in detail here

http://www.coderanch.com/t/664616/JDBC/databases/insert-statement-slow-maria-db
 
Knute Snortum
Bartender
Pie
Posts: 2908
62
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My guess is that it does the 10 inserts atomically.
 
abhinas raj
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:My guess is that it does the 10 inserts atomically.


i do not think so, as i am inserting each record individually.
 
Dave Tolls
Ranch Hand
Posts: 2112
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you got the code working that was in that other thread, as it still looks like it wasn't working.
 
abhinas raj
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Tolls wrote:Have you got the code working that was in that other thread, as it still looks like it wasn't working.


it was working. both working and not working code are there in the thread. working code i am pasting here again

 
Dave Tolls
Ranch Hand
Posts: 2112
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And if you don't have that BEGIN in there?

You're executing every single statement as it occurs, so I can't see how this code makes anything faster.
I also can't see how that BEGIN does anything at all in the current situation.

Is the connection auto-commit?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic