views:

18

answers:

1

This is an optimization question, mostly. I have many forms on my sites that do simple Inserts and Updates. (Nothing complicated)

But, several of the form's input fields are not necessary and may be left empty. (again, nothing complicated)

However, my SQL query will have all columns in the Statement. My question, is it best to optimize the Inserts/Update queries appropriately? And only apply the columns that are changed into the query?

We all hear that we shouldn't use the "SELECT *" query, unless it's absolutely needed for displaying all columns. But what about Inserts & Updates?

Hope this makes sense.

I'm sure any amount of optimization is acceptable. But I never really hear about this, specifically, from anyone.

A: 

Inserts and updates will be impacted if there are indexes on any of the columns being inserted/updated, so it's a compromise that has to be struck - is the table read more than it's add to/updated, or vice versa?

Assuming you aren't using parameterized stored procedures to perform these tasks, the shorter the text is for the SQL statement - the faster it should get to the server & then be executed.

OMG Ponies
That's what I thinking too! The shorter the statement, then logically, the faster the execution. Of course, I constantly get surprised by nuances in how the mysql engine performs. I am referring to any columns that can be for reading or updating only. Like a user's email address, or physical address.You make very good points, thanks!