This hack is coded a little inefficiently. I suggest that instead of of SELECTing everything ("*"), you select only the necessary items or columns/fields from the database. Also, doing a count() on a certain field with an INDEX is a lot faster than a count(*).
No offense please, didn't mean to bash you or your coding skills, but it's what I noticed since vBulletin tends to "rape" our server already and this hack is quite nice, and I don't want the hack to add to the load.