1

I have 2 tables, one of them contains BLOBs.

psh table
................................
ID
playerID
stateID
sceneID


ps table
..................................
ID
playerID
playerState

What i need to get is a count of the IDs from ps table grouped by sceneID (from psh table). So I'm joining the 2 tables and grouping. The problem is in this specific query the group by clause crashes the database and i get error 2013: lost connection during query.

If i try other queries, in which i use group by, it will work just fine.

this is my query, please help out:

select count(ps.ID) from innodb.player_spin as ps
JOIN innodb.player_state_history as psh  ON
psh.playerId = ps.playerId
WHERE psh.sceneId IN (9, 19, 29, 30)
group by psh.sceneId;
M Khalid Junaid
  • 63,861
  • 10
  • 90
  • 118

1 Answers1

0

The GROUP BY is from table psh. It should be the driving table and join with the non group by table:

select count(ps.ID) 
FROM player_state_history as psh
JOIN player_spin as ps ON
  psh.playerId = ps.playerId
WHERE psh.sceneId IN (9, 19, 29, 30)
GROUP BY psh.sceneId

This should speed things quite a bit if properly indexed on psh.sceneId

Jacques Amar
  • 1,803
  • 1
  • 10
  • 12