Home » questions » Optimize a simple MySQL query running slow because of an "OR" in the WHERE clause?

Optimize a simple MySQL query running slow because of an "OR" in the WHERE clause?

2006-08-10 16:33:10, Category: Programming & Design
SELECT * FROM mytable WHERE field1="test" OR field2="test" limit 1; This takes two seconds to run (vs. 0.00 for each search separately), and it refuses to use any index, even with FORCE INDEX. I would like to be able to run one search instead of two, and this seems very basic, but I can't find any info on how to do this! Please help me, MySQL gurus!

Answers

  1. weida

    On 2006-08-13 00:04:36


    You may use the access query tool "Advanced Access Builder" at http://www.download5000.com/page25449.aspx or http://www.dlkj.net/sqlBuilder , it allows you to visually build complete SQL scripts.
  2. David La Pierre

    On 2006-08-11 13:25:07


    Lol, I don't know http://en.wikipedia.org/wiki/Mysql