Altering queries?

Josh Berkus josh at
Fri Sep 21 13:13:03 UTC 2007

Marcus, KJ,

> Yes, but it's probably built in to your language and thus an awful lot 
> faster to do an isset() / in_array() or array_key_exists() (PHP) on an 
> array that you have in hand than to have a trip to the DB. In fact the 
> language may index arrays internally anyway. MySQL with an index will be 
> faster than MySQL without an index, but it will still be much slower 
> than local array searching.

Well, that's going to depend on the numbers we're talking about; I'd 
imagine that, *assuming the data and index was already cached in 
memory*, a good DB would do a better job of pulling a select 100 entries 
out of 2,000,000.  But out of 200?  No.  Where the tipping point is 
would depend on more factors than I want to put into an e-mail.

In any case, this is highly hypothetical.  I think you'll find that 99% 
of your users have < 50 friends, so why optimize for the special case?


More information about the memcached mailing list