Skip to content

Conversation

@reid-rigo
Copy link
Contributor

Description

Case.includes(queries: :ratings) is a heavy operation for large cases.

This optimizes JSON building with a method (Case#doc_ratings_by_query) to load just the needed ratings columns in one shot.

class UpdateQueryUpdatedAtWithRatings < ActiveRecord::Migration[7.1]
def change
execute <<-SQL
UPDATE queries SET updated_at = GREATEST(updated_at, (SELECT MAX(updated_at) FROM ratings WHERE query_id = queries.id))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively a new column could be added like ratings_updated_at

@epugh
Copy link
Member

epugh commented Mar 8, 2024

How about we go through this next Ruby Code Jam??? It hink it could be great!

@epugh
Copy link
Member

epugh commented Feb 6, 2025

@reid-rigo could we jump on a zoom and go through this.. I think my understanding has finally caught up enough over the past year to have a reaosnable conversation about this PR! We recently moved a lot of stuff to allow Quepid to have a case with 5000 queries (previosu feasible limit was like 300 or 500) and so I suspect this could help with some of the remaining bottle necks.

@reid-rigo
Copy link
Contributor Author

@epugh yeah let's chat about it. I'll see if I can refresh my memory

@stale
Copy link

stale bot commented Jul 19, 2025

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please do advocate for this issue and ideally submit a patch to get the attention of the maintainers!

@stale stale bot added the wontfix This will not be worked on label Jul 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wontfix This will not be worked on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants