Optimized SQL.