Update rebuild_indexes_analyze function

Made rebuild_indexes_analyze more efficient when gathering database
objects and when checking if objects are versioned.