Ask Your Question
0

How can NHibernate perform batch updates and inserts?

asked 2023-05-28 16:03:21 +0000

ladyg gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-05-28 16:17:01 +0000

bukephalos gravatar image

NHibernate provides two ways to perform batch updates and inserts:

  1. AdoNetBatchSize: This property allows you to specify the number of SQL statements that will be executed in a batch before sending them to the database. By default, this property is set to 1, which means each SQL statement is executed individually. Increasing the AdoNetBatchSize can improve performance by reducing the number of round trips to the database.

  2. Batch insert/update/delete: This feature allows NHibernate to group multiple inserts, updates or deletes for the same entity type into a single SQL statement. This can improve performance by reducing the number of overall SQL statements executed. To use batch insert/update/delete, you need to set the batch-size attribute on the entity mapping or on the session factory configuration.

Both of these strategies can be used together to further improve performance.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-05-28 16:03:21 +0000

Seen: 14 times

Last updated: May 28 '23