It would be good to add indexes on remoteUid, type, direction.