Cambly interview question

Optimizing a database query with indexing