Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 22, 2025

Addresses performance feedback from PR #9: topic.first_post access on line 45 triggers N+1 queries since the association isn't preloaded.

Changes

  • Changed includes from :topic to topic: :first_post to eagerly load the first post association
# Before
.includes(:topic, workflow_step: { workflow_step_options: :workflow_option })

# After  
.includes(topic: :first_post, workflow_step: { workflow_step_options: :workflow_option })

This eliminates one database query per workflow state when topic.first_post.raw is accessed during AI prompt construction.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: merefield <35533304+merefield@users.noreply.github.com>
Copilot AI changed the title [WIP] Update performance improvements based on feedback from PR #9 Fix N+1 query when accessing topic.first_post in AI transitions Nov 22, 2025
@merefield merefield marked this pull request as ready for review November 22, 2025 16:09
Copilot AI requested a review from merefield November 22, 2025 16:09
Copilot finished work on behalf of merefield November 22, 2025 16:09
@merefield merefield merged commit e982c4f into eliminate_n_plus_1 Nov 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants