You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was debugging the performance of a large query serialisation (read query) , and I stumbled upon something curious. There is significant amount of time being spent in AASM::Persistence::ActiveRecordPersistence.
Upon investigation, it seems that most of the time is being spent on attribute models. It seems to be coming from aasm_ensure_initial_state and aasm_column_is_blank, listing all attribute names.
I found a comment that this method is not using responds_to because of Rails 3 support. Given that it has been 10 years, I wonder if it we could consider migrating to responds_to, and if it would make it a bit more performant? After all in our case, we only have one AASM field in a very large model.
defaasm_ensure_initial_stateAASM::StateMachineStore.fetch(self.class,true).machine_names.eachdo |state_machine_name|
# checking via respond_to? does not work in Rails <= 3# if respond_to?(self.class.aasm(state_machine_name).attribute_name) && send(self.class.aasm(state_machine_name).attribute_name).blank? # Rails 4ifaasm_column_is_blank?(state_machine_name)aasm(state_machine_name).enter_initial_stateendendenddefaasm_column_is_blank?(state_machine_name)attribute_name=self.class.aasm(state_machine_name).attribute_nameattribute_names.include?(attribute_name.to_s) &&
(send(attribute_name).respond_to?(:empty?) ? !!send(attribute_name).empty? : !send(attribute_name))end
The text was updated successfully, but these errors were encountered:
I was debugging the performance of a large query serialisation (read query) , and I stumbled upon something curious. There is significant amount of time being spent in
AASM::Persistence::ActiveRecordPersistence
.Upon investigation, it seems that most of the time is being spent on attribute models. It seems to be coming from
aasm_ensure_initial_state
andaasm_column_is_blank
, listing all attribute names.I found a comment that this method is not using responds_to because of Rails 3 support. Given that it has been 10 years, I wonder if it we could consider migrating to
responds_to
, and if it would make it a bit more performant? After all in our case, we only have one AASM field in a very large model.The text was updated successfully, but these errors were encountered: