That could be due to the relatively inefficient wildcard match it performs for the input string (in this case *Ted*). Compared to sed which is just simply trying to find Ted in each line. By default Anope only searches 7 days of logs, not all of the logs, you could try passing +1d. 4.2 million lines of logs seems rather excessive though, maybe you should look into an alternative solution?