Page 1 of 1
Does MySQL have limits for the amount of rows?
Posted: Wed Sep 13, 2006 6:40 pm
by impulse()
I had the idea to create a hit counter for my site by adding 1 to the number of rows in a table on each page loads. Will the table ever reach a limit? Is this generally bad scripting or not such a bad idea?
Posted: Wed Sep 13, 2006 6:52 pm
by Luke
mysql is made to store millions (sometimes billions) of records. It's limits are more dependant on the server than on mysql itself (I believe)
Posted: Wed Sep 13, 2006 6:53 pm
by jayshields
The limit varies on operating systems, it's in the millions/billions on any though.
Adding a row to a table on page hits is one of the worst ideas I've ever heard though. Just increment an integer in a field each page hit.
Code: Select all
UPDATE `table` SET `hits` = `hits`+1
Posted: Wed Sep 13, 2006 6:54 pm
by feyd
Tables can have hundreds upon hundreds of millions rows. The limitation is more dependant on your operating systems' limits.
Posted: Wed Sep 13, 2006 6:56 pm
by jayshields
Lol, we all posted at the same time with almost identical posts.
Posted: Wed Sep 13, 2006 7:00 pm
by Luke
wanna know why?
cuz we're freakin awesome! That's why!
Posted: Wed Sep 13, 2006 7:50 pm
by s.dot
I believe the limit is dependant on the max file size allowed on the operating system. So I wouldn't say it can hold X amount of rows, but rather X amount of data.
To the OP.. that scripting is terrible

Do what was said above to simply increase an integer.
Posted: Thu Sep 14, 2006 4:19 am
by onion2k
scottayy wrote:To the OP.. that scripting is terrible

Do what was said above to simply increase an integer.
Hate to buck the trend*, but I would do this (and do do it) the way the OP is suggesting. A simple incrementing number doesn't tell you anything beyond the number of times the page has been viewed. If you add a record per hit (with things like the session id and page url (inc. variables)) you can track exact path a user has taken through your site with the amount of time spent on each page. That's very useful information.
* I love to buck the trend.
Posted: Thu Sep 14, 2006 4:46 am
by impulse()
My plan is to add onto this to include IP address, time & date. Just need to increase my skillz to deal with the IP grabbing

Posted: Thu Sep 14, 2006 5:27 am
by GM
To get the IP Address it is extremely simple... look in the manual at the $_SERVER superglobal (specifically $_SERVER['REMOTE_ADDR'])
Posted: Thu Sep 14, 2006 6:39 am
by impulse()
GM wrote:To get the IP Address it is extremely simple... look in the manual at the $_SERVER superglobal (specifically $_SERVER['REMOTE_ADDR'])
That worked a treat mate. I've gone back to logging each visitor as a row which includes the visitor number and IP. Does it get to the point in a PHP coders life when they stop patting themselves on the back for their creations because it all seems to have gotten old? I've only just started in the last few weeks and I find myself feeling really proud for the most simple things

Posted: Thu Sep 14, 2006 6:46 am
by GM
I haven't been doing PHP for long (maybe 6 months, only as a hobby), and I'm still at the back-patting stage
