Mantaro Brands interview question

how can you optimize query?