php-general | 2001072
Date: 07/31/01
- Next message: Richard Lynch: "[PHP] Re: "Call to a member function on a non-object" error!"
- Previous message: Richard Lynch: "[PHP] Re: move_uploaded_file permissions"
- In reply to: Jeff Lewis: "[PHP] Large Calculations"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> I have a mySQL database holding baseball stats and I want to calculate
> rankings on these players. Now I'd obviously want this to be as fast as
> possible since I go through about 600 players but where is it best to make
> them? In the SQL command itself or in PHP?
Not even a close race: SQL will win every single time.
Databases have been optimized to hell and back for DECADES to do this kind
of stuff fast.
PHP has only been alive for 5 years.
You do the math :-)
Not that PHP is slow, but SQL will win for sure.
> 1. batting average x .05
> 2. doubles + triples + HR divided by at bats
> 3. runs scored divided by at bats
> 4. rbi's divided by at bats
> 5. stolen bases divided by at bats
> next add up the 5 totals then multiply that total by 200. It's a bse 100
> system. a rating over 100 is very good.
Not sure exactly which columns you have in your database, but do something
not unlike this:
select (hits/atbats * 0.05 + ((doubles + triples + homers)/atbats) +
runs/atbats + stolen/atbats) * 200 as rating from players order by rating
desc
That's all 1 line, no matter what you see...
For 600 hundred players, this isn't going to even be a burp on the system to
do the work.
-- WARNING richard <email protected> address is an endangered species -- Use ceo <email protected> Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Richard Lynch: "[PHP] Re: "Call to a member function on a non-object" error!"
- Previous message: Richard Lynch: "[PHP] Re: move_uploaded_file permissions"
- In reply to: Jeff Lewis: "[PHP] Large Calculations"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

