Reduced memory consumption of synclegacydb script