Fix wrong GROUP_BY on performance stats (bug 1010728)

WIP