In reply to DaveHK:
A friend and I both had similar experiences (me with mountain biking, him with trail running), where our training had included long workouts, and intense workouts, but then on race day the combination of length AND intensity was too much and we both had bad cramps.
Reading up on cramps later on lead me to some of the stuff that IainRUK on here referenced about ultra-distance running, like this:
http://www.irunfar.com/2012/07/waterlogged-a-dogma-shattering-book.html and this
http://www.pikeathletics.com/blog/exploring-causes-of-exercise-associated-m... (and others..)
It seems that cramps are a neurological effect, only indirectly related to blood chemistry. It's your brain telling over-used muscles to shut down.
However, lots of people still say that salt tablets or salty food relieves cramp - this is backed up by a study in which people drank pickle juice (urrrr). The interesting thing here is that salt tablets or salty juice relieve cramp in 30 to 90 seconds. This is held to be too fast for blood chemistry changes and reinforces the idea that it's neurological: the TASTE of salt makes the brain stop cramping up the muscles.
So current advice seems to be to increase intensity in training, carry salt tablets just in case and don't drink too much. All things that I will bear in mind if I ever do another race.