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.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 03-19-2011, 10:33 AM   #1
Jakez
Confirmed User
 
Jakez's Avatar
 
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;
__________________
[email protected] - jakezdumb - 573689400

Killuminati

Last edited by Jakez; 03-19-2011 at 10:39 AM..
Jakez is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-19-2011, 10:52 AM   #2
woj
<&(©¿©)&>
 
woj's Avatar
 
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

Last edited by woj; 03-19-2011 at 11:00 AM..
woj is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-19-2011, 11:00 AM   #3
mafia_man
Confirmed User
 
mafia_man's Avatar
 
Industry Role:
Join Date: Jul 2005
Location: icq#: 639544261
Posts: 1,965
Quote:
Originally Posted by Jakez View Post
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;
Why not increment a counter and index that column? You could cache as well, I take it these clicks don't change the top 50 very often (if I understand your system correctly).
__________________
I'm out.
mafia_man is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-19-2011, 11:04 AM   #4
mvc333
Registered User
 
Industry Role:
Join Date: Oct 2009
Location: Florida
Posts: 36
Quote:
Originally Posted by Jakez View Post
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;
I'd me more concerned about your sql statement than the table size. SQL databases can easily handle millions of rows per table but what are your indexes like vs your queries? Care to post the sql and index info??
mvc333 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-19-2011, 11:22 AM   #5
borked
Totally Borked
 
borked's Avatar
 
Industry Role:
Join Date: Feb 2005
Posts: 6,284
Quote:
Originally Posted by Jakez View Post
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;

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

Last edited by borked; 03-19-2011 at 11:23 AM..
borked is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-19-2011, 04:39 PM   #6
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,359
bad db design
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


WP Stuff
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-19-2011, 04:47 PM   #7
blackmonsters
Making PHP work
 
blackmonsters's Avatar
 
Industry Role:
Join Date: Nov 2002
Location: 🌎🌅🌈🌇
Posts: 20,488
MySQL...



__________________
Make Money with Porn
blackmonsters is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-19-2011, 04:55 PM   #8
DangerX !!!
Confirmed User
 
DangerX !!!'s Avatar
 
Industry Role:
Join Date: Feb 2011
Location: La Isla Bonita Power Level: ❤❤❤❤❤❤❤❤❤❤
Posts: 886
Quote:
Originally Posted by blackmonsters View Post
MySQL...



If not MySQL then what?
__________________
This is sig area!
DangerX !!! is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-19-2011, 07:27 PM   #9
blackmonsters
Making PHP work
 
blackmonsters's Avatar
 
Industry Role:
Join Date: Nov 2002
Location: 🌎🌅🌈🌇
Posts: 20,488
Quote:
Originally Posted by DangerX !!! View Post
If not MySQL then what?
Knowing how to write an old school program works pretty good.

__________________
Make Money with Porn
blackmonsters is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-19-2011, 07:48 PM   #10
Tempest
Too lazy to set a custom title
 
Industry Role:
Join Date: May 2004
Location: West Coast, Canada.
Posts: 10,217
Quote:
Originally Posted by Jakez View Post
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;
Simple answer... Depends on how beefy your server is... Regardless, the DB is designed poorly to do this sort of thing. Don't know why you'd want to track every single click to every image by every IP. If all you really want is to sort the images, that can be accomplished much easier.
Tempest is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-19-2011, 10:07 PM   #11
Ron Bennett
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
Ron Bennett is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-19-2011, 10:15 PM   #12
Brujah
Beer Money Baron
 
Brujah's Avatar
 
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.
__________________
Brujah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-19-2011, 10:18 PM   #13
bl4h
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 ....
bl4h is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-19-2011, 11:17 PM   #14
Kiopa_Matt
Confirmed User
 
Industry Role:
Join Date: Oct 2007
Posts: 1,448
Quote:
Originally Posted by bl4h View Post
if you're doing logging, then log it to a database thats not used to sort the pics ....
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!
Kiopa_Matt is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-19-2011, 11:24 PM   #15
cam_girls
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
cam_girls is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-20-2011, 05:13 AM   #16
lopez
Confirmed User
 
Join Date: Jul 2002
Posts: 299
normalization needed.
lopez is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-20-2011, 06:21 AM   #17
Due
Confirmed User
 
Due's Avatar
 
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
Due is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-20-2011, 08:39 AM   #18
blackmonsters
Making PHP work
 
blackmonsters's Avatar
 
Industry Role:
Join Date: Nov 2002
Location: 🌎🌅🌈🌇
Posts: 20,488
__________________
Make Money with Porn
blackmonsters is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-20-2011, 08:45 AM   #19
mafia_man
Confirmed User
 
mafia_man's Avatar
 
Industry Role:
Join Date: Jul 2005
Location: icq#: 639544261
Posts: 1,965
Quote:
Originally Posted by lopez View Post
normalization needed.
But that's not degrading performance, that's just wasting space.
__________________
I'm out.
mafia_man is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-27-2013, 03:14 AM   #20
bl4h
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
bl4h is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.