mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-25 20:46:48 +00:00
This (should) considerably improve traces like https://app.datadoghq.com/apm/trace/917632173599137280?spanID=3163385094622710144&env=production&sort=time&colorBy=service&spanViewType=metadata&graphType=flamegraph&shouldShowLegend=true by fixing the following 3 N+1s ``` user: root GET /admin/customers.json?enterprise_id=4 USE eager loading detected Customer => [:enterprise] Add to your query: .includes([:enterprise]) Call stack /usr/src/app/app/serializers/api/admin/customer_with_calculated_balance_serializer.rb:24:in `balance_value' /usr/src/app/app/serializers/api/admin/customer_with_calculated_balance_serializer.rb:9:in `balance' /usr/src/app/app/controllers/admin/customers_controller.rb:20:in `block (2 levels) in index' /usr/src/app/app/controllers/admin/customers_controller.rb:17:in `index' user: root GET /admin/customers.json?enterprise_id=4 USE eager loading detected Spree::Address => [:state] Add to your query: .includes([:state]) Call stack /usr/src/app/app/serializers/api/address_serializer.rb:14:in `state_name' /usr/src/app/app/controllers/admin/customers_controller.rb:20:in `block (2 levels) in index' /usr/src/app/app/controllers/admin/customers_controller.rb:17:in `index' user: root GET /admin/customers.json?enterprise_id=4 USE eager loading detected Spree::Address => [:country] Add to your query: .includes([:country]) Call stack /usr/src/app/app/serializers/api/address_serializer.rb:10:in `country_name' /usr/src/app/app/controllers/admin/customers_controller.rb:20:in `block (2 levels) in index' /usr/src/app/app/controllers/admin/customers_controller.rb:17:in `index' ``` This popped up after improving the balances calculation. Now, that it's fast, it's clear that are more performance problems on that endpoint. We'll see if there are any left after this.