Database Failure Overnight

The database failed overnight leaving the service completely dead about 5 minutes after I went to bed. A query which went bad brought the server down by locking all the tables while it attempted to join together millions of rows (actually probably 100’s of millions of rows) which ran all night and actually never returned….