- Feature Articles
- CodeSOD
- Error'd
-
Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
The only thing this is faster at, is in filling a screen with one query.
Admin
It's a faster way to get your Lines of Code (LOC) metric up.
Admin
If Ted had just enough knowledge to be dangerous, given the outcome, I'm wondering what that knowledge is, and what its source is.
Admin
If column "updater" is not unique, Ted's code will update much more than only the row with change = @change.
Admin
In that case, your first task is to stop using silly prefixes.
Admin
Given the naming conventions, I'm going to be generous and assume that
updater
is the primary key oftbl_updater
. Our submitter didn't have anything to say on the subject beyond, "This is what the query should be," so it's a good assumption.Admin
Apparently Ted thinks it's faster to set the "date" column twice. Kudos for creativity!
Admin
I don't say this often, but too bad they weren't using MySQL. It has a quirk where it doesn't allow using a subquery that references the same table in the WHERE clause of an UPDATE or DELETE query.
Admin
I was going to say this. But the more I looked at this code, the more I believe there's a good possibility that updater is null.
Admin
Maybe Ted learned that from some Atari shareware database package back in the day.
Admin
Oh, it's faster alright. In the future, anyone who looks at the code will instantly understand Ted's "value" to the project. Much time saved.
Admin
It gets slower a lot faster
Admin
Maybe Ted's original method was to print out the database tables, put the printouts on a wooden desk, take photos and give the photos to his teenage daughter to mark with a highlighter.
Admin
Is it rude to point out that is in fact faster than his neurons firing?
Admin
They are both one-liners, so it wouldn't actually move a needle in that regard - and even if you break them down in two lines, well, it's still a 1:1 ratio to the broken down original statement :-)
Admin
well, it is certainly faster. Rather have one query that is slightly slower than needed, than have the original six querys with a sub-query in each. Of course it is faster.
Admin
Classic case of premature optimization:
Admin
And not even in backticks, so it will be treated as a function...