Slow queries to remote PostgreSQL db
If the only difference is local vs remote, then the problem has to be your round trip times.  The actual internal query execution is not aware of the type of connection used.  However I also wonder if you are also running your dev system on a different database.  In that case, caching could be very different and could also make a significant difference.

I see a few ways to solve this problem.  The first is just to have a dev copy of the database for the site on your dev system.  This data could then be sanitized so that if your dev system is compromised or lost (supposing it is a laptop for example) the data exposure is minimal.  Then you can test performance on a system which can do caching specific to your dev work and will not have the round trip.

The second approach is to build a much faster tunnel, and to possibly throw a lot more RAM at the db server.