[Cloud] Please help with optimizing a SQL query