Fix for not optimized queries.