Another quick question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
atomix
Forum Newbie
Posts: 3
Joined: Tue Oct 07, 2003 4:27 am

Another quick question

Post by atomix »

I recently posted about showing a total count using SUM(*), and i have it included on my page as a tiny script to sum out the total count and amazingly the count was over 13,000 downloads. all of a sudden now the page is loading a bit slower since i added it, is it the script working thats doing that or could it just be my server going slow. and if its the script doing it, is there anyway to speed the process up?
User avatar
thomas777neo
Forum Contributor
Posts: 214
Joined: Mon Mar 10, 2003 6:12 am
Location: Johannesburg,South Africa

Post by thomas777neo »

Over what period of time were those 13,000 files downloaded? Anyway,

You can also use this select statement:

Code: Select all

SELECT count(*) from table_name as total
This should be a little quicker, yet I feel this isn't the primary problem.

I feel it has to do something with the server.

What is the size of the file been downloaded aswell?
User avatar
wmasterj
Forum Commoner
Posts: 40
Joined: Mon Aug 18, 2003 5:52 pm
Location: Stockholm, Sweden

Post by wmasterj »

maybe you could have one field in the database updated the hole time containing the downloads. You figure out how, but now the visitor doesn't have to go through all the fields it just adds +1 with the field counting downloads and +1 in the file which is downloaded ;) :?: .... i hope that helps ya out!

That way you have one 'general' count and one 'specific' count for every file.
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

inserting a new record for every download is a baaaaad idea, what you need to do is to change the table and have 1 row per file, so

ID filename downloads
1 bla.zip 110
2 d.zip 25


would be ok,u can check for number of downloads simply by fetching whats in "downloads" field :)
Post Reply