How not to use a database
I'd been meaning to share a bit of Luser-Programmer code I found in a site I
was fixing and this seems like as good a time as any.
On this site there was an HTML form with a drop-down generated from the
contents of a table. This was populated by a very basic "SELECT ID, Name FROM
Table" query. The page which processed the form had a bit of code to look up
the matching name for the passed ID. An experienced developer could have
written the entire thing in five minutes while blind drunk.
Granted, this was the work of a not-particularly-bright ASP/VBScript[1]
luser,
but the code was still amazing. Instead of the textbook SQL statement you'd
expect, the "programmer" open an ADO Recordset, loaded the entire table into
memory and then checked every single row (complete with 5 unnecessary
conversions) to see if it was the right one[2].
Nothing like switching from a full table scan to a WHERE on an index column to
improve speed. Just cleaning up the code and removing the more obvious bonehead
programmer mistakes (some of which rivaled the above) gave a visible speed
improvement of at least an order of magnitude and the new site, including the
security fixes & enhancements was around 10% of the original's size. The best
part, of course, is that this was from a fairly well known company in the area
and our client had most assuredly not paid entry-level cargo-cult programmer
rates.
| [1] |
The individual Ll ratings are definitely multipled in this case. |
| [2] |
"Is this one my ass? I
don't know, it might be my elbow. Why is this so hard?!!!" |
Date posted: 2nd April 2000