Size Transactions Appropriately
Performance impact: Large
INSERT, DELETE or
UPDATE), incurs a file system write operation when the transaction
commits. File system I/O affects response time and may affect throughput, depending on
how effective group commit is.
Performance-sensitive applications should avoid unnecessary file system write operations at commit. Use a performance analysis tool to measure the amount of time your application spends in file system write operations (versus CPU time). If there seems to be an excessive amount of I/O, there are two steps you can take to avoid writes at commit:
-
Adjust the transaction size.
-
Adjust whether file system write operations are performed at transaction commit. See Use Durable Commits Appropriately.
Long transactions perform fewer file system write operations per unit of time than short transactions. However, long transactions also can reduce concurrency. See Transaction Management.
-
If only one connection is active on a database, longer transactions could improve performance. However, long transactions may have some disadvantages, such as longer rollback operations.
-
If there are multiple connections, there is a trade-off between transaction log I/O delays and locking delays. In this case, transactions are best kept to the natural length, as determined by requirements for atomicity and durability.