This error says that your database internally ran out of memory while executing your query. This can happen when you JOIN and GROUP with too many tables. It happens because it can require that all those tables plus various intermediate result sets being required to be in memory simultaneously.