14, February 2012

how to get an overhead? - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  Databases  >  MySQL
Topic: how to get an overhead?
« previous next »
Pages: [1] Print
Instabuck - The easy way to sell digital products online

Author Topic: how to get an overhead?  (Read 1427 times)
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« on: Aug 11, 2006, 10:26:16 am »

Hello,

I know that a optimized table layout reduce the overhead for a n table.

I have this table to collect some visitor stats:
Code:
CREATE TABLE `visits` (
  `id` int(11) NOT NULL auto_increment,
  `ip_adr` varchar(15) NOT NULL default '',
  `referer` varchar(250) NOT NULL default '',
  `country` char(2) NOT NULL default '',
  `client` varchar(100) NOT NULL default '',
  `visit_date` date default NULL,
  `time` time NOT NULL default '00:00:00',
  `on_page` varchar(100) NOT NULL default '',
  `hostname` varchar(100) NOT NULL default '',
  PRIMARY KEY  (`id`)
) TYPE=MyISAM;

I use this table in several website and there are not really problems, but now I noticed a big overhead (592,816     Bytes), how does this happen?


Last blog : A new Wordpress theme for our blog
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5779
46271 credits
Members referred : 3



« Reply #1 on: Aug 11, 2006, 10:33:51 am »

Do you use UPDATE or DELETE statements?

BTW as you are using this table only for logging the overhead is not a real problem, and you can allways use a tool like this Wink

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #2 on: Aug 11, 2006, 10:59:39 am »

yes, I delete one time a month the records which are older then 12 month, I see that this is the problem...

I read this data also vor statistics is this a reason that the whole thing will slow down?


Last blog : A new Wordpress theme for our blog
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #3 on: Aug 11, 2006, 11:01:51 am »

for example this query need several records to execute 300.000 records

SELECT ip_country.country AS variable, COUNT(*) AS value FROM visits AS tbl LEFT JOIN ip2nationCountries AS ip_country ON ip_country.code = tbl.country WHERE tbl.country <> ''


Last blog : A new Wordpress theme for our blog
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5779
46271 credits
Members referred : 3



« Reply #4 on: Aug 11, 2006, 11:04:57 am »

The reason for slow down is that you use grouping functions when you show up the stats.

The why to do this faster is JOIN most of those data with other tables. Eg. the referer and the client fields.

But the real way to do this fast is to use some form of caching like awstats do, because in any way the parsing of this data is a slow process....

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #5 on: Aug 11, 2006, 11:17:04 am »

yes that's true the sql statement wasn't complete:

SELECT ip_country.country AS variable, COUNT(*) AS value FROM visits AS tbl LEFT JOIN ip2nationCountries AS ip_country ON ip_country.code = tbl.country WHERE tbl.country <> '' AND hostname = 'www.finalwebsites.com' GROUP BY tbl.country ORDER BY value DESC LIMIT 0, 10

I'm using group, but how to optimize the table with joins I have only two tables...


Last blog : A new Wordpress theme for our blog
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5779
46271 credits
Members referred : 3



« Reply #6 on: Aug 11, 2006, 11:24:35 am »

You have to split it to more tables...

And you can start by the hostname. Insted of using the actual hostname you will use the id of it in the hostnames (index that field)

Actually that was the reason that I stop developing my statistics program....

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #7 on: Aug 11, 2006, 11:29:04 am »

Quote
Actually that was the reason that I stop developing my statistics program....

that sounds not good,

last week I wrote a function to limit the visitors access...Sad


Last blog : A new Wordpress theme for our blog
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5779
46271 credits
Members referred : 3



« Reply #8 on: Aug 11, 2006, 11:36:20 am »

Good luck then....

Smiley

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=3630
Tags : design awstats Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  Databases  >  MySQL
Topic: how to get an overhead?
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Feb 14, 2012, 10:49:32 am





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.