The vast majority of my time as a developer is spent in little pieces of code all around our architecture. It’s pretty difficult to get a birds-eye view of a live system to see overall trends. That’s why I love New Relic. It was easy to see that our web servers were spending more time handling the bounce API than the email API.

That didn’t meet my expectations at all! The email API gets ten times the requests the bounce API gets! This was what targeted the bounce API for improvement.

The bounce API is powered by Elasticsearch. Through New Relic, I was able to determine that the vast majority of the time spent was querying Elasticsearch. So, I took a look at the query. It was using a bool query, with a structure like:

With this solid change under my belt, I wasn’t planning on making any other changes to this specific query. While doing other research on Elasticsearch, I did see something odd. All the example queries in the Elasticsearch docs use a filtered query. It’s an odd format really and the docs just talk up the benefits of using filters over queries. I knew that already, so I ignored it. But it kept popping up (really, all the examples use this format). So, I tried it.