Freelancer:
draugoz
Better solutions
You should apply index on your database... I added additional checking against SQL syntax, so you will be informed if something is wrong with that.