Re: optimizing OR query

2002-04-25 Thread Myk Melez
[EMAIL PROTECTED] wrote: >The form "Select foo.id From foo, bar..." is giving you a cross-product. A >cross-product emits a row for every combination of rows from each of your >tables. The Explain results seem to be consistent with this. What I'd >suggest is that you try a Join on your tables. >

optimizing OR query

2002-04-25 Thread Myk Melez
How do I optimize the following query? SELECT foo.id FROM foo, bar WHERE foo.id = bar.foo_id AND foo.field = 'baz' OR bar.field = 'baz'; Only a small number of records from each table match the query conditions, but MySQL takes forever to execute it. No wonder, when EXPLAIN says it needs to