Direct (Saudi Arabia) interview question

How to optimize query for efficient results