Jump to content

Recommended Posts

Hi

 

I have a cron Job that calls a php page that deletes old Msql data

every 5hrs or so

 

 

I have been thinking what would be the more efficient way to do this,

at the time of display or time of insertion, or just keep doing it via cron job?

 

I have a php page that displays data

 

$query=" SELECT * FROM visits WHERE page='$page' && vcode='1' ORDER BY id DESC LIMIT 20";
$result=mysql_query($query) or die(mysql_error());
while($row =mysql_fetch_array($result))

 

 

 

and another php page that inserts it

$queryup="UPDATE visits SET vcode='0' WHERE ip='$ip' && page='$page'";
$resultup=mysql_query($queryup) or die(mysql_error());

$query="INSERT INTO visits VALUES('NULL', '$ip', '$refer', '$page', '$flag', '$country', '$region', '$city', '$now', '1')";
$result=mysql_query($query) or die(mysql_error());

 

Looking for advice, on the most efficient and safest way to remove old data

 

Thanks

Sonny

Honestly it wouldn't make a difference as you are running a query to delete the data in both methods.  It all depends on how often you do it.

 

You are either running a query to remove more results once every couple hours or running multiple queries more often to remove less results.

 

I'd stick with the method you are already using, less queries = better performance

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.