Re: better functionality in query ?

From: Date: Fri, 06 Apr 2001 09:38:17 +0000
Subject: Re: better functionality in query ?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-47427@lists.php.net to get a copy of this message
On Friday 06 April 2001 01:57, you wrote: > NOTE(!): LIKE '%foo%' DOES NOT SCALE. It looks like you are making a > phone book, which could get to be a lot of numbers. On the other hand > 'foo%' oddly scales to hundreds of thousands of records without any > problems (make sure it's key'd!). Well, if you think a bit about it it's not odd at all. For "%foo%" the DB has to examine the entire string until it finds an occurence of "foo" or until it reaches the end - and it can not use any (normal) index. for it. For "foo%" it just has to examine the first three chars - that's even faster than "WHERE phone = 'foobar-something'" and works very nicely with a perfectly normal index. -- Christian Reiniger LGDC Webmaster (http://sunsite.dk/lgdc/) I saw God --------- and she was black.

« previous php.general (#47427) next »