Depends on the programming environment: if it's a O(n) operation anyway, meaning you don't the times indexed, and your computation is colocated with the data and the db interface is using lazy sequences...
(Also, real-life systems of course do things inefficiently all the time)
(Also, real-life systems of course do things inefficiently all the time)