Question: I have `iptables` setup on 2 `servers`. 

`Server#1` is public and `Server#2` only allows the `ip address` of `Server#1` to have `ACCESS`.

`Server#2` has a `mySQL` database that `Server#1` queries.

I ran a query and it took a long time to complete.

I found that after I ran `service iptables restart` on `Server#2` the query ran instant.

What could have been causing the `iptables` to take so long for allowing access?

How am I able to prevent this from happening in the future?

Answer: 
This sounds as if the two events are unconnected to me.

You've probably run the query, then it got stored in the query cache, so when you re-run the query the results are fetched from cache rather than scanning the tables to retrieve the data.
it might be helpful if you actually listed the iptables.. I agree it's probably not related but if you have some kind of qos/traffic limiting it may be interesting to see. you can also try running an strace -f on the mysql process while you query both times to see what's going on.