It is an excellent idea to keep your database in good health. Under AdminCP » Database you can select for how long messages are to be stored in the database, delete guests which effectively removes used guest names etc. These settings do nothing by themselves - they are applied through a file called
cron.php which you must call once a week, once a day or even every hour.
If you are unfamiliar with the built-in cron, the easiest way to setup a cron schedule to call your
cron.php is by using a 3rd party service. We can recommend cron-job.org or of course you can Google for another.
Our recommendation for a chat on a shared hosting account is to store no more than 20k messages in the database.