Michael J. Pawlowsky wrote:
> Because you will be downloading 500,000 rows... And I don't really
> think that was the point. Who cares what the example is. Personally I
> was quite impressed with great explanation.
I second that it was a great explanation! Please don't get me wrong!
And furthermore I will only download one row two times:
select count -> one row
select ... limit count/2, 1 -> one row
> I would have simply said a chunk of code that runs on the server that
> the client can call. And this guy took the time to put together a
> really good reply with an example.
I don't say that the example is bad, I only said that in MySQL you can
do this without a SP.
>
> Mike
>
Wolfram
>
> Wolfram Kraus wrote:
>
>> [...]
>>
>>> Suppose you have a table with a million records, test scores from
>>> a widely taken exam for example. You need to find the median mark
>>> - NOT the average! - so your algorithm needs to read all million
>>> records, sort them into ascending or descending sequence by the
>>> test score, then read exactly half way through the sequenced list
>>> to find the middle record; that's the one that contains the
>>> median score.
>>>
>>> If that work were to happen on the client, the client would have
>>> to fetch a million records, sort them all, then read through half
>>> of those records until it found the middle record; then it would
>>> report on the median mark. There would clearly be a lot of
>>> network traffic involved in getting all those records to the
>>> client, sorting them and then reading through the sorted records.
>>>
>>>
>> [...] Pardon my ignorance, but why can't you do this (in MySQL)
>> with a "select count ..." and afterwards a "select ... order by...
>> LIMIT"? All the work is done on the server, too. No need for a SP
>> here.
>>
>> Wolfram
>>
>>
>
>