8000 Optimization to map hits to AR objects in one query rather result.length queries. by jamster · Pull Request #9 · angelf/escargot · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Optimization to map hits to AR objects in one query rather result.length queries. #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jamster
Copy link
@jamster jamster commented Jan 28, 2011

This optimization sets the query to pull ids only (:ids_only option in Rubberband) and then compacts the array and passes that into the find method. This makes for a single query rather than having one query for each hit returned. It also compacts and uniqifies the array.

@pfeiffer
Copy link
pfeiffer commented Feb 8, 2011

Cool!

This commit will raise an exception if ElasticSearch returned an ID that was deleted in the meantime, and doesn't fit well with the multi-model search. I dont find the :quick_search-option is the right way to go - but I agree that the performance hit on fetching each and every object is not worth it.

What I've implemented in my projects using Escargot is a layer between my application and Escargot. I only fetch the IDs via Escargot, and make sure only to fetch AR-models on the records I actually need in my application - eg. after paging/slicing has been done. This also allows options to the finder, eg. :include => [:image] to reduce N+1 queries.

Preferably something like this would be implemented in Escargot, as the current implementation isn't very optimized.

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
0