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.
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.