Skip to content

Commit

Permalink
Fix N+1 query with preload
Browse files Browse the repository at this point in the history
  • Loading branch information
johnf committed May 11, 2024
1 parent 6387d64 commit 2a265bb
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions app/oai/item_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ class ItemProvider < ApplicationProvider
sample_id 'AA1-001'

source_model OAI::Provider::ActiveRecordWrapper.new(
# FIXME: We should have collection to fix a N+1 query but it makes the query take 14 seconds
::Item.public_items.includes(
:essences, :subject_languages, :content_languages, :countries, :access_condition,
:collector, :data_types, :data_categories, item_agents: %i[user agent_role]
),
).preload(:collection),
limit: 100
)

Expand Down

0 comments on commit 2a265bb

Please sign in to comment.