Heey, that looks nice. I want to use stored procedures for everything it looks simple!
update foo set viewcount = viewcount + 1 where..
That's valid SQL, preforming addition on an integer field?
Thanks for the tips too. I usually assume everything to do with the database is resource expensive, so things like doing one query instead of two if I can is usually in the back of my mind.
That last comment about caching, do you mean that — in your example, for example — the select query will use the incremented viewcount from memory of the first line?