Blogs

fast paging in the real world

Some time ago I attended the "Optimisation by Design" course from Open Query¹. In it, Arjen teaches how writing better queries and schemas can make your database access much faster (and more reliable). One such way of optimising things is by adding appropriate query hints or flags. These hints are magic strings that control how a server executes a query or how it returns results.

An example of such a hint is SQL_CALC_FOUND_ROWS. You use it in a select query with a LIMIT clause. It instructs the server to select a limited numbers of rows, but also to calculate the total number of rows that would have been returned without the limit clause in place. That total number of rows is stored in a session variable, which can be retrieved via SELECT FOUND_ROWS();  That simply reads the variable and clears it on the server, it doesn't actually have to look at any table or index data, so it's very fast.

This is useful when queries are used to generate pages of data where a user can click a specific page number or click previous/next page. In this case you need the total number of rows to determine how many pages you need to generate links for.

The traditional way is to first run a SELECT COUNT(*) query and then select the rows you want, with LIMIT. If you don't use a WHERE clause in your query, this can be pretty fast on MyISAM, as it has a magic variable that contains the number of rows in a table. On InnoDB however, which is my storage engine of choice, there is no such variable and consequently it's not pretty fast.

My Eep

I spent last week in San Francisco, attending DrupalCon. Like many geeks, I prefer to have a laptop with me at conferences, so I can take notes, check email and work on stuff if I need or want to.

My laptop is a rather lovely HP 6730b with a lot of RAM that does a whopping 1680 x 1050 as native resolution. Great for graphics and having lots of terminals open - less great for portability. HP also seems to have taken the 12 cell add-on battery for it off the market, so it only gives me about 2½ to 3 hours of run-time (with wi-fi enabled) as well.

Asus Eeepc 1005PAt DrupalCon I developed netbook envy, so upon arriving home I decided I needed something a lot more portable and with far better battery life.

I did a bit of research and found that all manufacturers offer virtually identically spec'd netbooks that contain an Atom N450, 1GB RAM, 250GB HDD and a 10.1" screen. The only point of difference seems to be the battery size, which ranges from 3 cell to 6 cell Li-ion.

A friend told me he'd just bought an Eeepc 1005P for just over $400, which is actually much cheaper than the competition. Sadly that was with a 10% discount campaign, which is no longer running. Still, the 1005P was at least $30 cheaper than the closest competitor and it does come with a 6 cell battery.

Ada Lovelace Day; Women in technology

I was just asked if I was going to write a blog for Ada Lovelace day this year. And yes, yes I am.

Earlier this year I actually met a bunch of really cool women who work in technology jobs!

In no particular order (apart from alphabetically) I'd like to mention Angela Byron, Liz Henry, Emma Jane Hogbin and Brenda Wallace.

When you meet any of them, buy them a $beverage; they deserve it :-)