diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-11-17 03:12:57 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-17 03:12:57 +0900 |
commit | bbae710a405ce92074c1666dcf859196c29e2ed2 (patch) | |
tree | 39862ca83075119e54a5cec8530530b271508ba8 /activerecord/test/fixtures | |
parent | 8bfa617e9990b05061c2f481afe87e055b6a6106 (diff) | |
download | rails-bbae710a405ce92074c1666dcf859196c29e2ed2.tar.gz rails-bbae710a405ce92074c1666dcf859196c29e2ed2.tar.bz2 rails-bbae710a405ce92074c1666dcf859196c29e2ed2.zip |
Avoid creating extra `relation` and `build_arel` in `_create_record` and `_update_record` (#29999)
Currently `_create_record` and `_update_record` in `Persistence` are
creating extra `unscoped` and calling `build_arel` in the relation. But
`compile_insert` and `compile_update` can be done without those
expensive operation for `SelectManager` creation. So I moved the
implementation to `Persistence` to avoid creating extra relation and
refactored to avoid calling `build_arel`.
https://gist.github.com/kamipo/8ed73d760112cfa5f6263c9413633419
Before:
```
Warming up --------------------------------------
_update_record 150.000 i/100ms
Calculating -------------------------------------
_update_record 1.548k (±12.3%) i/s - 7.650k in 5.042603s
```
After:
```
Warming up --------------------------------------
_update_record 201.000 i/100ms
Calculating -------------------------------------
_update_record 2.002k (±12.8%) i/s - 9.849k in 5.027681s
```
30% faster for STI classes.
Diffstat (limited to 'activerecord/test/fixtures')
0 files changed, 0 insertions, 0 deletions