optimized last_checked query