Fixed logic of calculating the number of queries executed by other threads than current