Igor's advice is very good - just restrict the SQL query so it only returns results with message size < 120. Simple - do it in the query code so you don't need to do it in C++.

Along these lines,...