Forum: Ruby on Rails Optimizing OR Queries in Rails and MySQL

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
685baf5b7f0b8718b00cc9980ec467e0?d=identicon&s=25 Moodang (Guest)
on 2009-05-01 12:14
(Received via mailing list)
According to MySQL doc, I must use union and temporary tables.

It seems I have to do something along the line of this:

http://www.ricroberts.com/articles/2007/09/25/mysq...

There are cases where I use OR queries quite often. I am talking about
queries like this "where column_1 = 123 OR column_2 = 123". It seems
MySQL indices cannot properly optimize this.

Are there plugins or snippets out there that automagically hide the
complexity of using temporary tables for such queries?
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-05-01 12:16
(Received via mailing list)
On May 1, 10:38 am, Moodang <moodang...@gmail.com> wrote:
> According to MySQL doc, I must use union and temporary tables.
>
> It seems I have to do something along the line of this:
>
> http://www.ricroberts.com/articles/2007/09/25/mysq......
>
> There are cases where I use OR queries quite often. I am talking about
> queries like this "where column_1 = 123 OR column_2 = 123". It seems
> MySQL indices cannot properly optimize this.

I don't think that's quite true - on mysql5 it should be able to do an
index merge:
http://dev.mysql.com/doc/refman/5.0/en/index-merge...

Fred
This topic is locked and can not be replied to.