# Delete all logs
TRUNCATE log;


# Delete old connection data (only used for stats)
DELETE c, cs
  FROM connections c
  LEFT JOIN connections_source cs ON (c.id_connections = cs.id_connections)
    WHERE c.date_add < 'YYYY-MM-DD 00:00:00';
    
OPTIMIZE TABLE connections, connections_source;


# Delete all guest without entry in customer table
DELETE g
 FROM guest g
 LEFT JOIN customer c ON (g.id_customer = c.id_customer)
   WHERE c.id_customer IS NULL;
     
OPTIMIZE TABLE guest;


# 404 erors
DELETE FROM `pagenotfound` WHERE `date_add` < 'YYYY-MM-DD 00:00:00' ;
# Sent mails
DELETE FROM `mail` WHERE `date_add` < 'YYYY-MM-DD 00:00:00';