PostgreSqlSegmentStore: improve performance

Insert segments and all associated rows and flags as a single query.
Improves performance by 10x-15x.