Executing a scan query