thedepotnetwork Posted August 26, 2008 Share Posted August 26, 2008 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 More sharing options...
Mchl Posted August 26, 2008 Share Posted August 26, 2008 Show us table structure? Link to comment https://forums.phpfreaks.com/topic/121426-php-mysql-optimization/#findComment-626155 Share on other sites More sharing options...
awpti Posted August 26, 2008 Share Posted August 26, 2008 Run the query by hand in the mySQL console and see how long it takes to run. Make sure you have properly indexed your data - a lot of amateur DBAdmins don't consider the importance of indexes. Link to comment https://forums.phpfreaks.com/topic/121426-php-mysql-optimization/#findComment-626447 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.