Rob's Blog

Postings from the world of Rob Ferrer
  • rss
  • Home
  • About
  • Gallery

MySQL Optimisation Trick using EXISTS

January 20, 2009 | 5:57 pm

One for the geeks I’m afraid.

I’m developing a site with quite a complicated menu system getting details using equally complicated database queries. In various places in the menu, I needed to find out whether to display a particular sub-menu. To do this I had some SQL to check whether any products existed at that particular point.

The SQL to do this took quite a while to execute (in one case over 30 seconds), which is obviously too long to wait to load a page.

I realised that my SQL statements were selected all appropriate products, where as they in fact only had to check whether any existed.

I could have just added a LIMIT to just return the first row, but if my statement had any ordering etc this wouldn’t help. I don’t want the first row (I don’t care about the data), just to know whether there is one. I knew there must be a better way.

I discovered EXISTS, which although isn’t documented very much, seems to do exactly what I want very simply. The solution is to surround my existing SELECT statement as follows:

SELECT 1 FROM DUAL WHERE EXISTS ( [SELECT statement here] )

That’s it. I can plug any SELECT statement I like in, and it tells me (very quickly) whether any results would be returned. A very useful trick I’m sure I’ll use in future.

Comments
No Comments »
Categories
Uncategorized
Tags
MySQL, SQL, web, Web Development
Comments rss Comments rss
Trackback Trackback

Touchscreen Proof of Delivery – Why Bother?

January 15, 2009 | 11:28 am

I’ve received a few parcels recently where I’ve been asked to sign a touchscreen device as proof of delivery rather than a piece of paper. Not one of these time has the squiggle on the screen looked anything like my signature. This isn’t because it’s hard to sign the screen, it’s just the sensor doesn’t correctly sense where it’s being pressed.

As an example, here is the signature reported as my proof of delivery from Parcelforce this morning:

signature

This is one of the better ones I’ve seen recently, but it barely resembles my real signature (I won’t post it here in case some clever identity thiefs try and use it).

The proof of delivery on their site also states it was signied by “R FARRAR”, despite the parcel being addressed (correctly) to me, and me spelling my surname to the driver. Again, this is one or the better interpretations, having had “FARA” in the past!

Why do they even bother using these touchscreens since they clearly don’t work? When they were testing the system did they say “well, it doesn’t work, but we’ll use it anyway”!? It would be very easy for me to claim this delivery never arrived!

Comments
No Comments »
Categories
Uncategorized
Tags
Parcelforce, post, rant, touchscreen
Comments rss Comments rss
Trackback Trackback

One of the funniest things I have read in a while

January 8, 2009 | 2:27 pm

I’ve just finished reading the BBC’s report on the Best Bushisms. I’m sure everyone know’s the term by now – amazingly ridiculous comments from George Bush.

I’ve heard a few of them before, but reading them all together was laugh out loud funny! It’s also pretty worrying that this man has been running the most powerful nation in the world for the past eith years – I’m just glad it’s over soon.

Some of my favourites:

“Our enemies are innovative and resourceful, and so are we. They never stop thinking about new ways to harm our country and our people, and neither do we.”
Washington DC, 5 August, 2004

“I think war is a dangerous place.”
Washington DC, 7 May, 2003

“You know, one of the hardest parts of my job is to connect Iraq to the war on terror.”
CBS News, Washington DC, 6 September, 2006

“Rarely is the question asked: Is our children learning?”
Florence, South Carolina, 11 January, 2000

“I’ll be long gone before some smart person ever figures out what happened inside this Oval Office.”
Washington DC, 12 May, 2008

See the original article for more, and if you want more fun – throw a shoe or two.

Comments
No Comments »
Categories
Uncategorized
Tags
bushisms, funny, George W. Bush
Comments rss Comments rss
Trackback Trackback

Links

  • Dell Special Offers
  • Ferrer Consulting Ltd
  • My LinkedIn Profile
  • Yuwie – social networking
  • Zopa

Tags

Android baby led weaning blogging cashback eBay email funny gadgets GDI GDI Goldrush Get Rich Quick google Google Wave Homepages Friends HTC Hero HTC Sense Isabel junk mail kayaking mobile MySearchFunds Norton Antivirus openid outdoors show Paternity phone photography post Post a Day rant review rodeo search security spam Symantec t-mobile the mobile outlet web Web Development welcome woopra wordpress WordPress 2.5 Yahoo

Recent Photos

DSC_0169.JPG
DSC_0158.JPG
DSC_0103.JPG
DSC_0098.JPG

Meta

  • Register
  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox