improved sql query performance (subselects)