HUE-1847 [metastore] Dropping loads of dbs or tables makes the script to timeout

Optimized code