Does MySQL have a memory ceiling you can set?

If you accidentally do a cartesian join which returns billions of rows, is there a MySQL feature that can (for example) tell that the memory allocation/consumption is going through the roof and subsequently terminate that query in order to protect the overall health of MySQL?

We mistakenly ran a cartesian join the other day and it ate up all of the memory on the box. Ideally, we would be able to set a param which would help to ensure that a query process would never consume more than X bytes before its automatically killed.

Thank you,

I don’t know such a feature, but you could use maatkit: mk-kill for queries that run for too long or mk-loadavg to take action upon high load. You could also combine the two and only kill long running queries when the load gets high.

You can try setting max_join_size. es.html#sysvar_max_join_size