On Thu, Oct 17, 2002 at 08:50:43PM +0200, Corin Langosch wrote:
> the table has about 12.000 rows total but the query should return
> a max of about 100. mysql should split the query into two queries
> and merge the results.
> may be this could be done by joining the same table two times
> and query each table only for one of the OR expression.
> i'll try but for future versions of mysql, this should
> be internally done i think... ;)
> 
> Thursday, October 17, 2002, 4:07:01 PM, you wrote:
> CL>> are normal indexes. Unluckily a query like:
> CL>> ------
> CL>> EXPLAIN SELECT * FROM `telegramme` WHERE to_id = 3157 or owner_id = 3157
> CL>> ------
> CL>> returns very bad results:
> CL>> ------
> CL>> table  type  possible_keys  key  key_len  ref  rows  Extra
> CL>> telegramme ALL to_id,owner_id NULL NULL NULL 11488 where used
> CL>> ------
> CL>> how could this be optimized or is this a bug of mysql, because the
> CL>> indexes exist but are not used (even if specified with use index(..)) ?!

Sounds like you should either:

ALTER TABLE telegramme ADD INDEX combined (to_id, owner_id);

or

SELECT * FROM telegramme WHERE to_id = 3157 UNION SELECT * FROM telegramme WHERE 
owner_id = 3157;

HTH

-- 
Shane Allen <[EMAIL PROTECTED]>

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to