A method and apparatus identifies SQL statements in a first transaction that specify modification operations that are commutative and associative. The SQL statements are combined into one SQL statement, and the one SQL statement is submitted to a database system. Optionally, or alternatively, multiple transactions can be grouped together into one transaction.