Some good news

This morning I ran 3 miles.

This is good. I can now run again. Stupid Achilles tendon appears to be fixed again.

I’ve felt like a fat slob over the last 11-12 weeks, missed a marathon and rediscovered cycling.

Lesson learnt: Next time my Achilles tendon goes (as no doubt it will knowing my luck), carve it out with a scapel and wait for a new one to grow back. That’ll teach it.

Twitter Weekly Updates for 2010-09-19

  • Welcome @LeaseDeskDotCom to Twitter. They have a very nice looking application (PHP/MySQL etc) *cough* #
  • Php / mysql performance blog post – removing the need for a separate 'count' query when searching. #mysql http://bit.ly/caEXlx #
  • Swinging in the park. #
  • You know you're going to have "fun" reviewing code when you see foo.php foo.20090101.php foo_old.php etc etc. #
  • Logging in to a website with username of "' or 1=1 or '". Result! #sqlinjection #security #

Late to the performance party

Everyone else probably already knows this, but $project is/was doing two queries on the MySQL database every time the end user typed in something to search on

  1. to get the data between a set range (SELECT x,y….. LIMIT n, OFFSET m or whatever) and
  2. another to get the total count of records (SELECT count(field) ….).

This is all very good, until there is sufficiently different logic in each query that when I deliberately set the offset in query #1 to 0 and limit very high and find that the of rows returned by both doesn’t match (this leads to broken paging for example)

Then I thought – surely everyone else doesn’t do a count query and then repeat it for the range of data they want back – there must be a better way… mustn’t there?

At which point I found:
http://forge.mysql.com/wiki/Top10SQLPerformanceTips
and
http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_found-rows

See also the comment at the bottom of http://php.net/manual/en/pdostatement.rowcount.php which gives a good enough example (Search for SQL_CALC_FOUND_ROWS)

A few modifications later, run unit tests… they all pass…. all good.

I also found some interesting code like :

$total = sizeof($blah);
if($total == 0) { … }
elseif ($total != 0) { …. }
elseif ($something) { // WTF? }
else { // WTF? }

(The WTF comment were added by me… and I did check that I wasn’t just stupidly tired and not understanding what was going on).

The joys of software maintenance.

August 2010

I would start with saying that not a huge amount happened in August… but then having thought about it, I’d be lying.

My right ankle is still in a state of disrepair – after hurting my achilles tendon … so no running, and I’m feeling fat / unfit as a result. I have got my mountain bike out of the shed and started to cycle again and found a few interesting routes around Dodford.

No running, means no Nottingham Marathon. They did however send me the running top – so I can at least pretend to people that I did it – “Look! I have the t-shirt to prove it!”. I am hoping to start running again within the next week …

In other news, Bromsgrove Hockey club started to do some stuff again, although my one big toe appears to have been broken in the first game back (hint: keep your feet out of the way). The second time out (last weekend) was on grass, which bought back some memories and was quite enjoyable (if only 30 minutes play in total).

Pale Purple moved office (yes, so don’t ask: “Did you do anything nice on the August bank holiday weekend?” …). The cost of the office is effectively the same, but now we have more room and it’s a far nicer (not dim and dingy).

I’ve also joined the local RoundTable group – although I’ve not coughed up any membership fees yet, so perhaps I’m premature in saying “joined”. The first event involved driving a motor bike around a rough field in the rain (good fun) and the second involved playing Discus Golf. All good stuff, and the guys seem a great bunch.

Rowan’s started to potty train; Anya smiles and makes cute noises. I’ve had a hair cut. Fun times.

Oh, and work’s been busy and somewhat stressful, but that’s all hopefully over with now (as $site_migration is complete).