.......... [ZBXNEXT-686] implemented a proper database clearing algorithm