mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
be9b68038e
This method can be used to see all of the fields on a model which have been read. This can be useful during development mode to quickly find out which fields need to be selected. For performance critical pages, if you are not using all of the fields of a database, an easy performance win is only selecting the fields which you need. By calling this method at the end of a controller action, it's easy to determine which fields need to be selected. While writing this, I also noticed a place for an easy performance win internally which I had been wanting to introduce. You cannot mutate a field which you have not read. Therefore, we can skip the calculation of in place changes if we have never read from the field. This can significantly speed up methods like `#changed?` if any of the fields have an expensive mutable type (like `serialize`) ``` Calculating ------------------------------------- #changed? with serialized column (before) 391.000 i/100ms #changed? with serialized column (after) 1.514k i/100ms ------------------------------------------------- #changed? with serialized column (before) 4.243k (± 3.7%) i/s - 21.505k #changed? with serialized column (after) 16.789k (± 3.2%) i/s - 84.784k ``` |
||
---|---|---|
.. | ||
associations | ||
attribute_methods | ||
attribute_set | ||
coders | ||
connection_adapters | ||
fixture_set | ||
locale | ||
locking | ||
migration | ||
railties | ||
relation | ||
scoping | ||
serializers | ||
tasks | ||
type | ||
type_caster | ||
validations | ||
aggregations.rb | ||
association_relation.rb | ||
associations.rb | ||
attribute.rb | ||
attribute_assignment.rb | ||
attribute_decorators.rb | ||
attribute_methods.rb | ||
attribute_set.rb | ||
attributes.rb | ||
autosave_association.rb | ||
base.rb | ||
callbacks.rb | ||
connection_handling.rb | ||
core.rb | ||
counter_cache.rb | ||
dynamic_matchers.rb | ||
enum.rb | ||
errors.rb | ||
explain.rb | ||
explain_registry.rb | ||
explain_subscriber.rb | ||
fixtures.rb | ||
gem_version.rb | ||
inheritance.rb | ||
integration.rb | ||
log_subscriber.rb | ||
migration.rb | ||
model_schema.rb | ||
nested_attributes.rb | ||
no_touching.rb | ||
null_relation.rb | ||
persistence.rb | ||
query_cache.rb | ||
querying.rb | ||
railtie.rb | ||
readonly_attributes.rb | ||
reflection.rb | ||
relation.rb | ||
result.rb | ||
runtime_registry.rb | ||
sanitization.rb | ||
schema.rb | ||
schema_dumper.rb | ||
schema_migration.rb | ||
scoping.rb | ||
secure_token.rb | ||
serialization.rb | ||
statement_cache.rb | ||
store.rb | ||
table_metadata.rb | ||
timestamp.rb | ||
transactions.rb | ||
translation.rb | ||
type.rb | ||
type_caster.rb | ||
validations.rb | ||
version.rb |