0e35bc609d
This request currently times out almost every night in production. It's because although Instructeurs are loaded in batches (default batch size is 1000), loading all dossiers for 1000 instructeurs is slow. Turns out the code executed after this query to compute notifications doesn't even use these dossiers. Indeed it is faster not to preload them: both the initial query and the total treatment time are shorter. Here's a quick benchmark made locally (but using production data): - Before this commit: Benchmark.measure { pp Instructeur.includes(assign_to: { procedure: :dossiers }).where(assign_tos: { daily_email_notifications_enabled: true }).limit(100).m ap(&:email_notification_data) } Only the initial query : 35s Total time : 97s - Without preloading dossiers: Benchmark.measure { pp Instructeur.includes(assign_to: :procedure).where(assign_tos: { daily_email_notifications_enabled: true }).limit(100).m ap(&:email_notification_data) } Only the initial query : 0.08s (400x faster) Total time : 29s (3,3x faster) Plus it doesn't timeout, of course. |
||
---|---|---|
.. | ||
administrateur_usage_statistics_service.rb | ||
agent_connect_service.rb | ||
api_entreprise_service.rb | ||
bill_signature_service.rb | ||
browser_support.rb | ||
clamav_service.rb | ||
commentaire_service.rb | ||
countries_service.rb | ||
dossier_projection_service.rb | ||
dossier_search_service.rb | ||
encryption_service.rb | ||
expired_dossiers_deletion_service.rb | ||
france_connect_service.rb | ||
geojson_service.rb | ||
instructeurs_import_service.rb | ||
ip_service.rb | ||
notification_service.rb | ||
pieces_justificatives_service.rb | ||
pipedrive_service.rb | ||
procedure_archive_service.rb | ||
procedure_export_service.rb | ||
serializer_service.rb | ||
staging_auth_service.rb | ||
zxcvbn_service.rb |