Performance on selecting all columns instead of specified attributes
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 38/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- rails, ruby
- Domain
- backend-api-design, databases, performance
Research direction
Start in lib/jsonapi/active_relation_resource.rb at the linked _model_class query and trace how Resource attributes and sparse fieldsets are represented. The work is done when those queries select only the fields needed by the resource and request fieldset, while preserving the existing records behavior and covering the relevant query paths.
Written by the indexing model from the issue text.
Description
Is there a reason the _model_class queries all columns?
This is a huge performance impact on models with many columns that may not ever be used by the resource.
It seems for performance reasons it makes sense to only select the attributes defined in the JSONAPI::Resource class.
A workaround for now is to override each resource using .select to retrieve only the fields that are specifically defined.
attributes :name, :address
def self.records(_options = {})
super.select(self.fields)
end
This should also take into account sparse fieldsets parameters, which would further limit which columns are selected.
- Dominant language
- Ruby
- Stars
- 2.3k
- Forks
- 546
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from JSONAPI-Resources/jsonapi-resources
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Difficulty 3/5 1-2 days Newbie friendliness 50/100
JSONAPI-Resources/jsonapi-resources#1488 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
JSONAPI-Resources/jsonapi-resources#1479 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
JSONAPI-Resources/jsonapi-resources#1477 · 3 comments · 1 reaction ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
All issues in JSONAPI-Resources/jsonapi-resources
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
ai-generated
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
hanami/hanami-cli#449 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
hanami/hanami-router#310 ·