Tracing statistics: improve performance of user node count

Joining the treenode and the user table is costly. Therefore, this
commit decomposes this into doing the count/aggregation first and then
getting the names to the user IDs in a fast second query.

In my test data set with 6677982 tree nodes this improves the
performance of this query from 2.4s to 1.5s.

This commit is part of dealing with issue #625.