Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Refactor build_arel

#4860

The following patch is a build_arel refactoring which includes some performance improvement:

https://gist.github.com/171408/a13d6c5a9eafc87b2e6b5eac7cce940b9339...

Reported by Emilio Tagua · June 14th, 2010 @ 05:42 PM

State: resolved
Milestone: 3.0.2
Assigned to: José Valim José Valim
Importance: Low

Activity

  1. Emilio Tagua
    Emilio Tagua
    • No changes were found…

    June 14th, 2010 @ 06:44 PM

  2. Emilio Tagua
  3. José Valim
    José Valim
    • Milestone cleared.
    • Assigned user set to José Valim

    June 16th, 2010 @ 05:39 PM

  4. Neeraj Singh
    Neeraj Singh

    The last change in the attached patch is

    - arel = @from_value.present? ? arel.from(@from_value) : arel.from(@klass.quoted_table_name)
    + arel = arel.from(@from_value) if @from_value.present?
    

    I have not analyzed the code fully but based on cursory look, it seems to me that a call to arel.from(@klass.quoted_table_name) is missing in else condition.

    June 16th, 2010 @ 05:53 PM

  5. Emilio Tagua
    Emilio Tagua

    No, there's no need to do that, that's why i didn't include it.

    It's just creating another new relation that will end up creating the same.

    If there's an edge case that i'm missing please let me know, all tests are passing with the patch, so if there's any issue that is introduced with this patch please let me know so i can change it and add proper tests.

    June 16th, 2010 @ 06:53 PM

  6. Emilio Tagua
    Emilio Tagua

    Oh, José both patches should be applied ;)

    June 16th, 2010 @ 06:58 PM

  7. Repository
    Repository
    • State changed from new to resolved

    (from [e061212e86ef0342fad1211fd980fc4b2195fe69]) Refactor build_arel: move joins out and simplify havings. [#4860 state:resolved]

    Signed-off-by: José Valim jose.valim@gmail.com
    http://github.com/rails/rails/commit/e061212e86ef0342fad1211fd980fc...

    June 19th, 2010 @ 11:59 PM

  8. José Valim
    José Valim
    • State changed from resolved to open

    Emilio, my git version was complaining that the second patch format was not valid. Could you please attach a new one? Links to commits in your fork is also ok. :)

    June 20th, 2010 @ 12:00 AM

  9. Emilio Tagua
    Emilio Tagua

    José,

    I applied build_arel_2.diff in a fresh master, I don't know why you couldn't.

    I attach a new patch with same changes, hope this time works for you.

    Thanks!

    June 20th, 2010 @ 07:55 PM

  10. Repository
    Repository
    • State changed from open to resolved

    (from [7b7cedcb8d53110492e7d51405986f3e8e899fa4]) Don't waste time building relations if there are no values presents. [#4860 state:resolved]

    Signed-off-by: José Valim jose.valim@gmail.com
    http://github.com/rails/rails/commit/7b7cedcb8d53110492e7d51405986f...

    June 21st, 2010 @ 12:11 AM

  11. Jeremy Kemper
    Jeremy Kemper
    • Milestone set to 3.0.2
    • Importance changed from to Low

    October 15th, 2010 @ 11:01 PM