|
Posted by The Natural Philosopher on 01/19/08 16:07
Steve wrote:
> "The Natural Philosopher" <a@b.c> wrote in message
> news:1200672543.35803.0@iris.uk.clara.net...
>
>> I've done this.
>>
>> Itseasierto do one big query, sort by whatever, iterate through the array
>> and write a new header everytime the name changes
>>
>> e.g. select surname,... from mytable, order by name gets the lot in teh
>> write order, and then a simple loop with something like posting a varablee
>> for the current first letter, and if it DIOES'T match the initial of the
>> name you are about to print, executing a bit of code that prints a new
>> header, aand set it to the current first name.
>>
>> PHP may be slow, but not as slow as the overhead on an SQL call with the
>> attendant file system shuffling.
>
> phil...i've never, ever seen *any* scripting language that can out-perform a
> database. sorry, i don't buy that.
I think you miss the point.
Consiuder <? ehoo "hellow world" ?>
with selects * from ALL_NHS_PATIENTS
for eaxmple. Bet you teh first is quicker.
So that mens your statement in teh limit is false. Some database queries
can be slower than some PHP statements.
Seciondly, which is quicker?
itersiaing through an array 27 times, on code thats already interpreted,
or pulling that array, possibly off disk, 27 times.
For a start, the php overhead to set up the call to mysql is probably as
bad as the php code to run through the array.
Secondly, what do you think MySQL IS, if not an interpreted language?
So in all case we are running a load of interepted code.
The only difference is that in the databsae area, there are two
interpreters involved, connected by a socket, plus potentally loads of
disk access, or at least RAM cached disk access.
Its patently OBVIOUS that the php will be faster.
that one (whatever is meant by that)sql
> query can run cached and be optimized by almost any db. whatever system
> shuffling is to be done, it certainly will be mechanically LESS than hitting
> the db n times to get the same result...especially considering that php is
> involved between calls rather than just one process.
>
Well that is what I said.
> make a believer of me, though, and i will happily change my mind. :)
>
I think you need to make it up first.
The choice is between loading the same data 27 times, and having simple
PHP code, or having the data loaded once, and using more complex php
code to run through it 27 times.
If the data is in anyway large, its vastly more efficient to load it
into PHP once, and then play games with it.
>
Navigation:
[Reply to this message]
|