Jump to content

Recommended Posts

You stated that every call of execute() creates a new prepared statement. I'd like to see evidence of this, because this is indeed an exceptional claim.

 

My code above demonstrates that calling prepare() once and execute() 10 times leads to one prepared statement. This is exactly what I expected, but you obviously doubt this result. So where's your code which shows that actually 10 statements get created?

 

 

 

 

You stated that every call of execute() creates a new prepared statement.

Yes, I still stay behind that statement, but need to check how mysql treats execute statement in a loop. But what I've seen this morning than, most of the new versions of databases to improve the performance just prepared the query only once when execute statement occurred in a loop.

 


Repeated execution

A prepared statement can be executed repeatedly. Upon every execution the current value of the bound variable is evaluated and sent to the server. The statement is not parsed again. The statement template is not transferred to the server again.

Well, thanks for the quote Barry. I found the same in the mysql documentation, and I'd suggest @OP to read up on it. So, obviously, there is nothing wrong in Jacques's script to call execute statement in a loop as I thought and stay corrected on it. I become confused by the fact that all versions of Firebird DB ( before 2.5, not sure for older version of mysql ), every execute statement occurred in a loop was prepared, executed and released upon every iteration, however, you are here to learn something new everyday :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.