If you perform automated searches, especially those that may occur frequently. It's probably in your interest to structure your queries to be efficient and quick-running.
The first thing to note is that WatchFox has three indexes. They cover players, coordinates (x, y, z), and time (millisecond precision).
Ideally, you should include at least one of these indexes (by using
-t in your query).
Note: You should include as much detail as you can regardless. Queries are quite high-level compared to the actual search that is performed. Additional detail can make things much faster.
Additionally, avoid filtering data once you receive it. If you need the data on two players, use
-p player1 player2 instead of searching for everyone and filtering them out.
Similarly, if you want to exclude a particular player,
-p !player1 will do just that and without having to transfer as much data (and consume that much more RAM).
Of course, if you're compiling the most busy players in the last day, let's say, iterating through a single search's results is perfectly reasonable.
The other mechanism WatchFox offers to keep search load down is searchN.
This search will start at the present, going backwards in time, and only match up to N number of events. If there simply wasn't enough hits, you'll get what was found, possibly nothing.
If you only need the last 10 events where someone said "bad word",
searchN(10, "-e player_chat -s bad+word") would serve you well.
Or you could just as easily only need the last event. Use 1 for N and the search will complete the moment a match is found. Last time a player joined:
searchN(1, "-p player1 -e player_join")
Again, using WatchFox's built-in tools is preferable to filtering the returned data on your own. Pulling off the last 5 events in an array 1000 long is much less efficient than only matching 5 to being with.
Links: Home | API Home | Tutorials | Searching | Event Naming | Block Events