Reply to post:

Tech rookie put decimal point in wrong place, cost insurer zillions

juice

>> Old code only referred to the fields by number, $row[0], $row[1], so a new column in the middle offset all the subsequent ones."

> There's your problem right there. It's an SQL system so nobody of any competence should do that. Had the code been adapted reused without changes from something older?

I've seen plenty of similar examples, written in the last decade or so. Sometimes it's because people aren't experienced developers, but it's also sometimes because people think they're being clever.

As the second comment here notes, in the legacy libraries used by PHP (and presumably, Perl, etc) indexing by the numeric column ID is measurably faster:

http://php.net/manual/en/function.mysql-fetch-array.php

(And it's probably still true today, but with modern hardware, I'm guessing the elapsed-time delta is significantly smaller. I've not had enough caffeine, nor do I have enough interest to knock up a test script!)

Personally, I value readability over "optimisations" like this - if you're reading and writing to a database, then disk and network I/O are the biggest factors when it comes to performance issues, usually by several orders of magnitude.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon