Try adding a WHERE time > now() - 5m or similar to limit the time range being queried.
WHERE time > now() - 5m