Shispare interview question

How to optimise database queries?