Re: difficult select problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Apr 9, 2009 at 1:39 PM, PJ <af.gourmet@xxxxxxxxxxxx> wrote:
[snip]
> Now the silly questions = often I am curious what effect the differences
> in code will have on performance.
> For instance, why are you using author.last_name LIKE '{$Auth}%' rather
> than LEFT('$Auth') ? As I have mentioned, it is not important what
> follows the A

The query optimizer can use an index on author.last_name to evaluate
"WHERE author.last_name LIKE '{$Auth}%' ". It simply seeks/scans the
index since the last_name values are ordered, and starts returning
values when it reaches the first row that begins with $Auth and stops
returning rows when it finds a value is greater than the pattern.

To evaluate "WHERE LEFT('$Auth', LENGTH('$Auth')) = '$Auth' ", the
server has to calculate a substring of last_name for every row in the
table and then compare those substrings to the value $Auth.

Andrew

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux