Re: Getting mysql_query results into an array

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

 



On Tue, 2007-02-13 at 18:22 -0600, Richard Lynch wrote:
> #2
> loop through mysql result set to build $array
> perform some kind of calculation upon $array
> 
> In this case, it's USUALLY much more efficient to write an SQL query
> to perform the calculation.
> 
> Databases are highly optimized for this kind of thing, and very
> efficient at it.
> PHP is a generalized programming language, and not so efficient for
> this kind of task.
>
> #2 does occasionally have an exception to the rule, where the SQL
> query is nasty and the PHP is fast and easy, but that's awfully rare.

I hear this all the time that the database should do as much as possible
"it's highly optimized" yadda yadda. I'm going to go out on a limb and
say that in a heavily loaded system, shoving all the work into the
primary bottleneck is a bad idea. 100 workers make light work, and that
would be the inherent power in horizontal scalability. Databases do not
scale well horizontally, machines loaded with Apache and PHP do,
especially when each machine doesn't expect the database server to do
all the work. In fact, I'd wager queries involving joins are another
bane on horizontal scalability since now the tables are forced to reside
on the same machine.

I could be completely wrong, I've never worked on an extremely loaded
server, but I get a tick every time someone says "shove all the work
into the query", and that usually happens when something doesn't feel
right :)

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

-- 
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