Reduce number of SQL queries for poll generating