Joomla jos_session table crash-Collection of common programming errors

I recently got the following error

DB function failed with error number 145
'TABLE\ jos_session' is marked as crashed and should be repaired
SQL=SELECT session_id FROM jos_session WHERE session_id ....

This was accompanied by my site crashing. I fixed it by truncating the table

truncate table jos_session

It can also be fixed by repairing the table

repair table jos_session

My question is, how can we prevent this table from crashing to begin with.