The activity stream has shown some serious slowness since 3.2. After a deep investigations we found some index issue but it was still slow with more than 5 items in most cases.
After deeper investigations I found that the getRelatedEvents function was called a lot and got quite slow. I also found that the database seemed to spend some times querying an empty table activitystream_events_param although this table is empty by default with the current activity stream usage we do.
I found this came from
XWIKI-6839 and that by removing the <map> mapping from activitystream.hbm.xml the previous speed was recovered.
Here are some speed results with activity entries="5" / with and without the mapping
Total time: 4766
Some of the getRelatedEvents time (not all calls are timed): 1617
Total time: 750
Some of the getRelatedEvents time (not all calls are timed): 175
Though we need to seriously redesign the activity stream as we probably should not have to call getRelatedEvents that much, we need to get back to the previous speed.
I don't really understand how querying an empty table even a lot of times can actually cost us 4 seconds. There seems to be something wrong either in the hibernate or in the mysql level.
Either somebody can find it, either I recommend getting rid of that mapping until we find a solution. At this point I don't think the feature is needed.