![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Industry Role:
Join Date: Jan 2004
Location: oddfuturewolfgangkillthemall!!!!!!!
Posts: 5,656
|
When does a MySQL table become too large?
Does a large database have the most impact on page load times or cpu load?
I have a table with about 1,000,000 entries so far, every time an image on the page is clicked it inserts an entry, and on every page load it groups the table by 'img' and then sorts by the amount of entries (or clicks) for each img, then displays them in order on the page, about 50 thumbs. I'm mostly concerned about how long it takes the page to load, does sorting this big of a table make the page load a lot slower or is it mostly unnoticeable? The table (size is about 70mb): ( `id` int(11) NOT NULL auto_increment, `time` int(11) NOT NULL, `img` varchar(255) NOT NULL, `country` varchar(30) NOT NULL, `c_ip` varchar(15) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=INNODB DEFAULT CHARSET=latin1; |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
<&(©¿©)&>
Industry Role:
Join Date: Jul 2002
Location: Chicago
Posts: 47,882
|
store country as chr(2) and ip as an int, will make the table way smaller... and if you are grouping by img, probably create an index on it...
![]()
__________________
Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000 Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager ![]() Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 | |
Confirmed User
Industry Role:
Join Date: Jul 2005
Location: icq#: 639544261
Posts: 1,965
|
Quote:
__________________
I'm out. |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 | |
Registered User
Industry Role:
Join Date: Oct 2009
Location: Florida
Posts: 36
|
Quote:
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 | |
Totally Borked
Industry Role:
Join Date: Feb 2005
Posts: 6,284
|
Quote:
What woj said, but 2 main concerns - 1. if you're grouping by image, the img really should be img_id - an int(x) where x is large enough for all your images (ie 4 if you have <9999 images). Far far faster to group an integer index than a varchar one, since the index will be numeric and a shit load smaller. 2. If this is the table that is getting hit with the inserts when an image is viewed, you really should make it an InnoDB table, not myisam.
__________________
![]() For coding work - hit me up on andy // borkedcoder // com (consider figuring out the email as test #1) All models are wrong, but some are useful. George E.P. Box. p202 |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
Making PHP work
Industry Role:
Join Date: Nov 2002
Location: 🌎🌅🌈🌇
Posts: 20,488
|
MySQL...
![]()
__________________
Make Money with Porn |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 |
Confirmed User
Industry Role:
Join Date: Feb 2011
Location: La Isla Bonita Power Level: ❤❤❤❤❤❤❤❤❤❤
Posts: 886
|
__________________
![]() ![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 |
Making PHP work
Industry Role:
Join Date: Nov 2002
Location: 🌎🌅🌈🌇
Posts: 20,488
|
Knowing how to write an old school program works pretty good.
![]()
__________________
Make Money with Porn |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#10 | |
Too lazy to set a custom title
Industry Role:
Join Date: May 2004
Location: West Coast, Canada.
Posts: 10,217
|
Quote:
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#11 |
Confirmed User
Join Date: Oct 2003
Posts: 1,653
|
DB reads, if the indexes and layout is decent, should be no problem - it's presumably the insertions that's killing your server's performance. Batch processing is likely the better way to do what you're seeking ...
More specifically, log the information to an append file with one entry per line (akin to a log file). Then every hour or whatever (imho, just once a day would likely be sufficient for what you're using that data for), run a cron job to processes that file into another file that contains the aggregate data for each image clicked - then add those click totals / additional data (ie. if also tracking IPs and/or countries, etc.) to the respective image totals / data already in the database. Ron
__________________
Domagon - Website Management and Domain Name Sales |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#12 |
Beer Money Baron
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
|
Only 70mb, might be a candidate for a well-managed memory table solution. You might also look at using INSERT DELAYED if you aren't.
__________________
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#13 |
Confirmed User
Join Date: Jul 2006
Location: Philadelphia
Posts: 1,282
|
why would you need to insert a row every click. inc a number on one row
if you're doing logging, then log it to a database thats not used to sort the pics .... |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#14 |
Confirmed User
Industry Role:
Join Date: Oct 2007
Posts: 1,448
|
That would be my suggestion. You're inserting a row everytime an image is viewed by IP address, then displaying images based on that data everytime a page is loaded? Don't do that. Separate the two processes.
__________________
xMarkPro -- Ultimate Blog Network Management Streamline your marketing operations. Centralize management of domains, pages, Wordpress blogs, sponsors, link codes, media items, sales and traffic statistics, plus more! |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#15 |
So Fucking Banned
Industry Role:
Join Date: Apr 2009
Posts: 2,968
|
If you search by indexes then the average time complexity is
O(log(tablesize)) which means you could have 1,000,000,000,000 rows and it would only take twice as long to search as 1,000,000 rows |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#16 |
Confirmed User
Join Date: Jul 2002
Posts: 299
|
normalization needed.
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#17 |
Confirmed User
Industry Role:
Join Date: Mar 2001
Location: Murrieta, CA
Posts: 3,620
|
Change the script so it actually build a page rather than making it on the fly.
Log clicks and impressions in a memory table and parse the clicks / impressions every few minutes. The more load you remove from mysql the more complex sorting you'll be able to do (more popular pix per referring domain, most productive design per domain etc)
__________________
I buy plugs Skype: Due_Global /Due |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#18 |
Making PHP work
Industry Role:
Join Date: Nov 2002
Location: 🌎🌅🌈🌇
Posts: 20,488
|
![]()
__________________
Make Money with Porn |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#19 |
Confirmed User
Industry Role:
Join Date: Jul 2005
Location: icq#: 639544261
Posts: 1,965
|
But that's not degrading performance, that's just wasting space.
__________________
I'm out. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#20 |
Confirmed User
Join Date: Jul 2006
Location: Philadelphia
Posts: 1,282
|
im going through my old posts and reading up. sorry to necropost but really....
a million rows is way too much just to sort 50 thumbnails. It doesnt even matter if your server can handle it, its a complete and total waste. you create a table with all the ips, you parse that table into a smaller table which the website will read from quickly. you purge that database as often as you wish it to be purged. the website would read from a simple table that has the number of unique clicks the image has. simple |
![]() |
![]() ![]() ![]() ![]() ![]() |