Fixed issue: High memory usage on db upgrade from older versions