-
guest_info table
I was having huge problems with the script the last few weeks due to mysql bottlenecks. I found the error after some research the problem was the guest_info table, it had over 1 million records. Is it supposed to keep a hold of all the guest infos visits? I dont see much point or need in it, anyway to turn it off? Im having to flush the tables every day now which isnt the most ideal solution
-
Re: guest_info table
Yes i wnat to turn it off too . How to do that admin???
-
Re: guest_info table
I know its nor a permanent solution but im running the following every 30 mins via cron...
Code:
<?php
## CUSTOMIZE SETTINGS FOR YOUR SITE ##
$db_host = "localhost"; // Change this if your MySQL database host is different.
$db_name = "db name"; // Change this to the name of your database.
$db_user = "db user"; // Change this to your database username.
$db_pw = "pass"; // Change this to your database password.
$datecut = $_SERVER['REQUEST_TIME'] - (30*24*60*60);
#######################################
// Connecting to your database
mysql_connect($db_host, $db_user, $db_pw)
OR die ("Cannot connect to your database");
mysql_select_db($db_name) OR die("Cannot connect to your database");
mysql_query("TRUNCATE TABLE `guest_info`");
# mysql_query("TRUNCATE TABLE `playlist`"); // un comment if you also don't want to track peoples entire playlists.
?>
Could should work ok, im no php expert so if there are errors I apologize but its working fine for me and speeded up the site a whole lot :D
-
Re: guest_info table
I found that this works on any of my sites (without having to configure each one for each site). My sites aren't horribly busy so I set this in cron to run every night at midnight.
Code:
<?php
include("include/config.php");
$db=mysql_connect ($db_host,$db_user,$db_pass) or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ($db_name);
mysql_query("TRUNCATE TABLE `guest_info`");
#mysql_query("TRUNCATE TABLE `playlist`"); // uncomment if you also don't want to track peoples entire playlists.
mysql_close($db);
print "Your guests and their play lists have been cleared from the database.\n";
?>
-
Re: guest_info table
You can actually streamline your code by removing the "datecut" line as it is not being executed for your statements.
There is actually another way to accomplish this on the mySQL side. It's a bit more complicated, but the end result would be that the entry is removed immediately after it is written. I'll have to write out a procedure and post it.
-
Re: guest_info table
Sweet! I'll modify the original to remove the time thingie. Thanks for bringing this to our attention and posting about it BTW.
-
Re: guest_info table
One other thing that I would change to your code is to add a mysql close statement. This way, you close out the connection that you open when you run the truncate (so as to free up resources). For your code, simply execute at the end:
-
Re: guest_info table
Awesome this code is a little better then mine, thank you :D
-
Re: guest_info table
So that's why my mysql is running at 130% CPU at times. Thanks for this. Luv it!
==============================================
http://www.TopFreaks.com - Black Amateur Porn
-
Re: guest_info table
mysql_close($db); added to the bottom. Thanks.