Performance: Select and pluck
MEDIUM IMPACT
This affects how efficiently data is fetched from the database and how much data is sent to the app, impacting page load speed and server response time.
User.pluck(:name)
User.select(:id, :name).map(&:name)| Pattern | Data Fetched | Server Processing | Network Payload | Verdict |
|---|---|---|---|---|
| select + map | AR objects with selected columns | High (object creation) | Large | [X] Bad |
| pluck | Only requested columns | Low (direct array) | Small | [OK] Good |