You don't need to optimize prematurely, but you should understand when/why/how to optimize something like this off the top of your head if you ever want to work at a company that deals with non-trivial amounts of data. If that's the hardest question I got asked at an interview, I'd never take the job.