Reduce SQL queries when retrieving filters