I think this isn't worth the if clause performance degradation from all 
queries. This scenario doesn't happen quite often.

Em domingo, 17 de março de 2013 07h44min27s UTC-3, Nathan Broadbent 
escreveu:
>
> Hi all,
>
> Was wondering if it would be worth adding a predicate optimization for 
> when a date range's `begin` and `end` are equal?
>     
>
> Post.where(:published_at => Date.new(2012,4,25)..Date.new(2012,4,25))
>
> #=> Post Load (3.0ms)  SELECT `posts`.* FROM `posts` WHERE 
> (`posts`.`published_at` BETWEEN '2012-04-25' AND '2012-04-25')
>
>
>
> is a tiny bit slower than
>
> Post.where(:published_at => Date.new(2012,4,25))
>
> #=> Post Load (2.7ms)  SELECT `posts`.* FROM `posts` WHERE 
> `posts`.`published_at` = '2012-04-25'
>
>
>
> We could add something like this, somewhere in *
> active_record/relation/query_methods.rb*:
>
> if val.is_a?(Range)
>   return val.begin == val.end ? val.begin : val
> end
>
>
>
> Please let me know if it's worthwhile, and I'll submit a pull request.
>
>
> Best,
> Nathan
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to