It would either be in the postbit function in admin/functions.php or in showthread.php (do you get this query lots of times on other pages?)
It would look something like:
PHP Code:
$DB_site->query_first("SELECT usergroupid FROM user WHERE userid=$bbuserinfo[usergroupid]");
Perhaps something in global.php or the phpinclude template contains this in a loop? (If its on pages other than showthread too).