Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Build sort if needed.
- Loading branch information
Showing
1 changed file
with
1 addition
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55f881e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its good to have a check if it's needed, but this unfortunately it still hurts performance in some scenarios.
For example, we're importing a lot of data to the Accounts, which means the search index gets rebuilt. Not being obvious, this was excluded from my rake task...
... and then viewing an index page suddenly takes minutes and does a lot of writes for a GET request, due to this and the before_filter .
IMO, ransack UI is doin' it wrong - it would be better to shift this to happening at the CRUD controller level for entities, or perhaps an after_save hook on the model.
55f881e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding @ndbroadbent to discussion
I've done a bit of benchmarking and the culprit of the slow search load is the 'attribute_select' function in ransack (not ransack_ui). See https://github.com/ernie/ransack/blob/v0.7.2/lib/ransack/helpers/form_builder.rb#L21 There's already a ransack issue open for this but doesn't seem to have been resolved yet. See activerecord-hackery/ransack#154
I'm interested in what you mean by the index page doing a lot of GET requests... this doesn't sound like typical behaviour?
55f881e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update: the 'attribute_collection_for_base' seems to be eating the time, This is called in attribute_select. Here's a benchmark:
55f881e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like translation is being overused...? A lot of calls and taking the time. Perhaps there is a more efficient way to code this?
55f881e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.