Hi Michael,
----- Original Message ----- From: "Michael Stassen" Sent: Tuesday, March 16, 2004 9:45 AM Subject: Re: BETWEEN > > Matt W wrote: > > > > The query using 2 BETWEENs with OR is exactly how it should be. It will > > be fast even in MySQL 3.23. OR is not a problem when the OR parts > > involve the same index. :-) > > Well, that makes sense, and it fits my own experience, but is it > documented anywhere? Or is that just supposed to be common sense? > > So far as I can see, the manual does not mention OR or BETWEEN in the > context of using an index, except for the mention of a new feature in > 5.0 <http://www.mysql.com/doc/en/OR_optimizations.html>. There have > been so many threads about slowness of OR or BETWEEN, often with UNION > as a suggested work-around, that in the absence of a clear description > of how this works and when UNION helps, it is easy to get confused. http://www.mysql.com/doc/en/MySQL_indexes.html - Under the example "WHERE clauses that use indexes": /* index = 1 OR index = 2 */ ... WHERE index=1 OR A=10 AND index=2 And for clarity, that should really have parentheses: index=1 OR (A=10 AND index=2) It's not a lot, but I don't think there ever was much about it in the docs -- except maybe pointing out that indexes wouldn't be used if the [top-level] OR branches don't reference the same indexed column (before 5.0). I don't see that mentioned anymore however... except indirectly in that "How MySQL Optimizes OR Clauses" section you mentioned. Matt -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]