Jump to content

PHP MySQL Optimization


thedepotnetwork

Recommended Posts

We seem to have a very slow load time on our redirect pages. Our tables are getting rather large as well. What do we do to change this query to be speedier, as well as handling upwards of 6,000,000 records on a given stats table.

 

Here is the code

<?php

include ("./includes/common.php");

$vendor_id = get_param("vendor_id");

if(!empty($vendor_id) && is_numeric($vendor_id))
{
$sSql = "INSERT INTO vendors_clicks_details (" .
		"vendor_id, " .
		"click_date, " .
		"click_type, " .
		"click_ip)" .
		" VALUES (" .
		tosql($vendor_id, "Number") . ", " .
		tosql(time(), "Number") . ", " .
		tosql(2, "Number") . ", " .
		tosql($_SERVER['REMOTE_ADDR'], "Text") .
		");";

$db->query($sSql);

$sSql = "SELECT vendor_url FROM vendors WHERE vendor_id = " . tosql($vendor_id, "Number");
$db->query($sSql);

if($db->next_record())
{
	$url = $db->f("vendor_url");

	header("Location: ".$url);
	exit;
}
}

?>

 

Here is a page sample

http://www.weddepot.com/united-states/wedding-professionals/wedding-vendors/profile/latterdaybride.html

 

when you click on the web link, it takes anywhere from 3 - 28 seconds to load the redirect...

 

Link to comment
https://forums.phpfreaks.com/topic/121426-php-mysql-optimization/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.