How to optimize a delete query with a subselect?
Use Multiple-Table Syntax of DELETE statement.

DELETE s.*, a.*
FROM statements s, agreements a
WHERE s.agreement_id = a.id
  AND a.created &lt; CURDATE() - INTERVAL 6 MONTH