Back to list
Views:   0
Replies:  0
Archived
,
Reply 1
Dennis:

I think you bring up an interesting question. I myself came from the database world and initially asked the same question.
However, to keep thing uniform and simple, there are only a hand-full of statements that usually are executed against the database.
Usually these are your typical CRUD (CREATE, READ, UPDATE, DELETE) operations: i.e. INSERT record, UPDATE record, DELETE record, and SELECT record.

As you said, with the UPDATE you could only update the columns that were changed. But to keep things relatively simple, usually the entire record, that is, all columns are updated, whether they were changed or not.

For example you may have a page where a USER name is changed, a second page where USER address is changed, and a third page where USER membership options are changed.  If all fields live in the same table, ie. USER, you will see that each of these pages uses the exact same UPDATE statement.   To make this possible you need to retrieve the entire record, before updating.

Indeed, this is redundant but databases are so fast nowadays that it does not really matter.  Also, updates are usually less frequent than SELECTS (or INSERTS most of the time). Now, if performance is extremely critical you could of course write a single, optimized, and lightweight UPDATE statement with only the relevant columns. This requires fine-grained SQL handcoding which is why it is typically not done that way.

Hope this helps.

Dan McMillan, Aug 10, 2011
thanx a lot
Mar 08, 2011
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Licensing       EULA       Sitemap      
© Data & Object Factory, LLC.
Made with    in Austin, Texas