I am using spring JPA/hibernate to insert data into postgres database.
Actually I need to insert records into two tables
I have below Entity
class
@Entity
@Table(name="TECHNOLOGY")
@SecondaryTable(name = "PERSON",
pkJoinColumns = @PrimaryKeyJoinColumn(name = "t_id"))
@Getter @Setter
public class TechEntity {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "TID_SEQ")
@SequenceGenerator(sequenceName = "t_id_seq", allocationSize = 1, name = "TID_SEQ")
private int tId;
private String tCode;
private String tType;
@Column(name = "name", table = "PERSON")
private String name;
And I have saveAll method in my service class:
repo.saveAll(list);
I configured the below properties as well to increase performance but no improvements.
spring.jpa.properties.hibernate.jdbc.batch_size = 200
spring.jpa.properties.hibernate.order_inserts=true
spring.jpa.properties.hibernate.order_updates = true
spring.jpa.properties.hibernate.jdbc.batch_versioned_data = true
spring.jpa.properties.hibernate.id.optimizer.pooled.preferred = pooled-lo
spring.jpa.properties.hibernate.generate_statistics=true
when trying to do insert 500-600 records, it is taking long time. Am I missing something? Can anyone please suggest, how can I improve performance. Thanks in advance.