You are here: Re: php vs mysql speed « PHP Programming Language « IT news, forums, messages
Re: php vs mysql speed

Posted by NC on 05/13/07 20:42

On May 10, 9:43 am, Ciaran <cronok...@hotmail.com> wrote:
>
> What about at the most basic level. For example would it be
> quicker to run:
> SELECT * FROM users WHERE userID IN
> (1,2,4,7,8,9,10,11,13,14,15,17,18,35,etc,etc,etc);
>
> or select each userID seperately in a PHP foreach loop with
> something like this statement:
> SELECT * FROM users WHERE userID=2 LIMIT 1;

The first approach would be much faster.

> I'm basically asking: Is it contacting the database that slows
> down PHP or is it the actual speed at which mySQL runs.

It depends on the query. For simple queries, the per-query overhead
is important, so one query is faster than several. For complex
queries, especially those that involve joins and sorting, splitting
one complex query into two simpler ones may be a viable option.

> I'm just looking for a rule of thumb here

There is only one rule of thumb here: when in doubut, test it out...

Cheers,
NC

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация