At 01:17 AM 3/20/2002, you wrote: >An Oracle DB programmer reviewed a query that I wrote and told me that >putting constants at the beginning of the query would make it slower. I >thought I'd go to the experts on MySQL and be told the truth one way of >the other. > >Example query: > >SELECT > TABLE1.COL, > TABLE2.COL >FROM > TABLE1, > TABLE2 >WHERE > TABLE1.COL='CONSTANT' >AND > TABLE1.COL=TABLE2.COL > > [ OR ] > >SELECT > TABLE1.COL, > TABLE2.COL >FROM > TABLE1, > TABLE2 >WHERE > TABLE1.COL=TABLE2.COL >AND > TABLE1.COL='CONSTANT' > >I know that indexes are important and such, the above is just an example >to give some visual. > >Thanks for any help you can offer. > >Rob.
Rob, The only thing to watch out for is that the constant should be the same data type as the column. Fox example, don't compare a Char to an Integer (or vice-versa) otherwise MySQL will have to convert the column on a row by row basis thus eliminating the use of the index.. Also if you perform a function on a column name, then it also can't use the index. So if you need to use functions it is best that you move the function to the constant side of the comparison if possible. Brent _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.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