Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't use after commit/rollback database hooks if the model instance …
…methods are not overridden This is faster than the previous code, at least when the defaults are used. In benchmarking with a mock database, it's about 10% faster for creates and 25% faster for updates. Note there is a 2-3% performance decrease for users who set use_after_commit_rollback = false manually, but I think this is a better default. The main advantage of doing this is that it automatically handles cases that were handled poorly by the previous default of always using after commit/rollback hooks. The previous default did not work well when using prepared transactions (which doesn't work with after commit/rollback hooks). The previous default also caused performance issues for transactions that saved many objects, as it created multiple closures for every object saved, keeping all closures and objects in memory until the transaction was committed/rolled back. In Sequel 5, after commit/rollback model hooks will be removed by default, and you'll have to use a plugin to enable them. It's recommended that any users using the model hooks switch to using the database level hooks. Note that this breaks backward compatibility slightly, in that use_after_commit_rollback now returns nil instead of true by default, and setting the value to nil will keep the default of checking for overridden methods, instead of treating it like a false value.
- Loading branch information
1 parent
882fe41
commit ead5e5e
Showing
5 changed files
with
52 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters