|
Posted by Boris Stumm on 05/10/07 16:47
Ciaran wrote:
> Hmm, 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;
In terms of complexity, both queries are equally complex, although the
first one looks a bit like there is some design issue. Anyways, doing it
the first way will be lot faster than doing it the second way (in my
opinion)
> I'm basically asking: Is it contacting the database that slows down
> PHP or is it the actual speed at which mySQL runs.
Depends :)
> The former suggests that one big query would generally be quicker
> while the latter suggests many basic queries would generally be
> quicker.
> I'm just looking for a rule of thumb here, not hard answers.
See my other post.
Navigation:
[Reply to this message]
|