The new query doesn't need to aggregate entire set and therefore works about twice faster.
Also the SELECT is not doing json encoding of usename, datname and query strings anymore, leaving this job to bg_mon.
In addition to that tests on travis are executed against postgres 9.3, 9.4, 9.5 and 9.6
Coverage increased (+1.02%) to 86.914% when pulling 1d3e93b24f06c0bf3df90f791b98e9dced4f1dc2 on feature/refactoring into 9412922efba655491ccebbcbfc5b7308d79b90c4 on master.
The new query doesn't need to aggregate entire set and therefore works about twice faster. Also the SELECT is not doing json encoding of usename, datname and query strings anymore, leaving this job to bg_mon.
In addition to that tests on travis are executed against postgres 9.3, 9.4, 9.5 and 9.6