Erick, Monday, July 29, 2002, 3:58:36 AM, you wrote: EP> i have a couple of questions about my SQL query.
EP> 1. if i want all rows in table 1 that may or may not have a counterpart EP> row in table 2, i use LEFT JOIN. this is HORRIBLY slow! why? if i make it EP> a simple join (i.e., without the words "LEFT JOIN") then it is a little EP> faster. EP> 2. secondly, i need to have an OR in my join clause. EP> where EP> (table1.col1 = table2.col1 or table1.col2 = table2.col1) EP> this is for a search procedure. if i remove the OR, it is much faster. EP> how can i get around this? i need to have the OR because of the search EP> engine in the website, but i need it to be fast. EP> 3. based on the OR condition, what kind of indices can i use? If your select is slow, use EXPLAIN SELECT to get info about your statement: http://www.mysql.com/doc/E/X/EXPLAIN.html Besides you didn't gave any info about your tables stucture, haven't provided your query. Check also the following sections of the manual which some info about index usage, LEFT JOIN and WHERE clause : http://www.mysql.com/doc/M/y/MySQL_indexes.html http://www.mysql.com/doc/W/h/Where_optimisations.html http://www.mysql.com/doc/L/E/LEFT_JOIN_optimisation.html -- For technical support contracts, goto https://order.mysql.com/?ref=ensita This email is sponsored by Ensita.net http://www.ensita.net/ __ ___ ___ ____ __ / |/ /_ __/ __/ __ \/ / Egor Egorov / /|_/ / // /\ \/ /_/ / /__ [EMAIL PROTECTED] /_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.net <___/ www.mysql.com --------------------------------------------------------------------- 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