I'm having a lambda do a query in mysql then save that query result to S3,where it will be used by another lambda to do something else with all that data.

Im running out of lambda memory since the query result is too big and is being saved to a variable before being sent to S3.

You guys have any idea of how can I approach this?