Post
Topic
Board Services
Re: Need PHP/MYSQL expert to fix my Bitcoin faucet
by
ahmedjadoon
on 14/02/2015, 08:14:06 UTC

Do you even SQL bro Tongue? I'll explain what this SQL statement is doing and why you're not correct in saying that this should be done PHP side. This SQL statement is getting
1. The count of all rows in balances (so the amount of users).
2. The maximum balance of any user (so the person with the most $$). To do this one PHP sided, you'd have to retrieve the whole balance row from the table with all of the data and then do it PHP sided. This would use more CPU than the SQL statement would.
3. The sum of the balances is just all of the balances in the table added together. This is the same as above and doing it using MySQL is far less resource intensive then getting the whole table and doing it with PHP.

Your statement about "12 calls to the SQL Server in the index.php" isn't necessarily an issue. You'll find that a lot of PHP files have quite a few more queries.

@OP: Try get information such as what pages are causing this issue with overusage of CPU from your host. I can try later on a VPS and see what the major issue is for you if you want. Are there any cron scripts running by any chance (haven't really looked at the code).
I just asked my host about this.I would really appreciate if you fix this before my host takes my site down.