On Wed, 2003-01-22 at 03:18, Steve Quezadas wrote:
> 
> ([Defendant] Query WITH a join - 8.79 seconds!
> EXPLAIN SELECT Defendants.CaseNumber FROM Defendants, Cases WHERE 
> Cases.CaseNumber = Defendants.CaseNumber AND Filed <= "1999-01-01" AND 
> (Defendant LIKE "owen%" OR Defendant LIKE "pitts%" OR Defendant LIKE 
> "general%");
> 
>+------------+--------+----------------------+-------------+---------+-----------------------+-------+------------+
> | table      | type   | possible_keys        | key         | key_len | 
> ref                   | rows  | Extra      |
> 
>+------------+--------+----------------------+-------------+---------+-----------------------+-------+------------+
> | Defendants | range  | CaseNumber,Defendant | Defendant   |      30 | 
> NULL                  | 82756 | where used |
> | Cases      | eq_ref | CasesNumber,Filed    | CasesNumber |      30 | 
> Defendants.CaseNumber |     1 | where used |
> 
>+------------+--------+----------------------+-------------+---------+-----------------------+-------+------------+
> 
Would a combined index on CasesNumber and Filed help ?

eg.
create index CasesFiled on Cases (CasesNumber, Filed);

The query might work out the 'Filed <= "1999-01-01"' without consulting
the table then.

==
Martin


---------------------------------------------------------------------
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