For our data we use a recursive query to group the data together.
We have created a stored procedure which calls all of our required queries together for quicker processing.
We create a temporary table which extracts the important information from the table, and then we run a recursive query on the table, which can be seen as taking all children and all parents from a node in a tree.
When running these components separately, we get the correct results in little time without crashing. However when running this query in a stored procedure it has one of three possible outcomes:
It runs the query as desired in very little time,
It crashes and gives an out of memory error: (ERROR 5 (HY000): Out of memory (Needed 19091736 bytes))
It crashes and gives a too big key error: (ERROR 1815 (HY000): Internal error: Using too big key for internal temp tables)
I have included a portion of the table which also gives the same error, it also creates the stored procedure.
To generate the errors call the following query a few times:
call getNums('3', '49d18acc-d3aa-45db-9efd-6d1a66971964');