reduce mem usage in saving index