unsider Posted July 27, 2008 Share Posted July 27, 2008 Here's the code I'm calling with: I'm calling with: <?php $ch = curl_init("URL"); curl_exec($ch); curl_close($ch); ?> The code: <?php if ($_GET['action'] == 'active' || $_GET['action'] == 'new') { $order_by = ($_GET['action'] == 'active') ? 't.last_post' : 't.posted'; $forum_sql = ''; if (isset($_GET['fid']) && $_GET['fid'] != '') { $fids = explode(',', trim($_GET['fid'])); $fids = array_map('intval', $fids); if (!empty($fids)) $forum_sql = ' AND f.id IN('.implode(',', $fids).')'; } else { $show = isset($_GET['show']) ? intval($_GET['show']) : 10; if ($show < 1 || $show > 50) $show = 10; $result = $db->query('SELECT t.id, t.subject, t.poster FROM forum_topics AS t INNER JOIN forum_forums AS f ON f.id=t.forum_id LEFT JOIN forum_forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id=3) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.moved_to IS NULL'.$forum_sql.' ORDER BY '.$order_by.' DESC LIMIT '.$show) or error('Unable to fetch topic list:', $db->error()); while ($cur_topic = $db->fetch_assoc($result)) { $subject_truncated = htmlspecialchars($cur_topic['subject']); echo '<li><a href="'.$config['base_url'].'/viewtopic.php?id='.$cur_topic['id'].'&action=new" title="'.htmlspecialchars($cur_topic['subject']).'">'.$subject_truncated.'</a> by: '.htmlspecialchars($cur_topic['poster']).'</li>'."\n"; } } return; } I'm using this to determine the load time: <?php $m_time = explode(" ", microtime()); $m_time = $m_time[0] + $m_time[1]; $starttime = $m_time; $round = 3; $m_time = explode(" ", microtime()); $m_time = $m_time[0] + $m_time[1]; $endtime = $m_time; $totaltime = ($endtime - $starttime); echo "<b>" . round($totaltime, $round) . "</b> secs"; Before calling the code above I was usually returning 0.004-0.009 secs on connection, after calling the code I am returning anywhere from 0.244-0.835 secs. While those numbers seem small, I am running a fast cable connection, so I shutter to think what those numbers would be on a slower conn. Is there anyway I can reduce the load time? Disable settings, rewrite my query, a different calling method, anything? Thanks a bunch. Quote Link to comment https://forums.phpfreaks.com/topic/116895-possible-methods-of-optimzing-this-i-dare-you/ Share on other sites More sharing options...
jonsjava Posted July 28, 2008 Share Posted July 28, 2008 this is a MySQL issue. you might want to move this to the MySQL Help forum. You'll get a better response there. Quote Link to comment https://forums.phpfreaks.com/topic/116895-possible-methods-of-optimzing-this-i-dare-you/#findComment-601229 Share on other sites More sharing options...
DarkWater Posted July 28, 2008 Share Posted July 28, 2008 That number reflects the server load time and has nothing to do with your internet connection speed. Quote Link to comment https://forums.phpfreaks.com/topic/116895-possible-methods-of-optimzing-this-i-dare-you/#findComment-601233 Share on other sites More sharing options...
Nhoj Posted July 28, 2008 Share Posted July 28, 2008 As darkwater said, it looks like that number is simply the amount of time it too to create the page. Not for the page to be sent to the user. Quote Link to comment https://forums.phpfreaks.com/topic/116895-possible-methods-of-optimzing-this-i-dare-you/#findComment-601575 Share on other sites More sharing options...
JonnoTheDev Posted July 28, 2008 Share Posted July 28, 2008 Run your query using EXPLAIN to see what indexes are in use. You can then decide to optimize the query or add indexes to the tables for performance. Quote Link to comment https://forums.phpfreaks.com/topic/116895-possible-methods-of-optimzing-this-i-dare-you/#findComment-601580 Share on other sites More sharing options...
samshel Posted July 28, 2008 Share Posted July 28, 2008 try moving conditions from ON clause to WHERE clause..i think it helps.. ON f.id=t.forum_id to WHERE f.id=t.forum_id Quote Link to comment https://forums.phpfreaks.com/topic/116895-possible-methods-of-optimzing-this-i-dare-you/#findComment-601629 Share on other sites More sharing options...
JonnoTheDev Posted July 28, 2008 Share Posted July 28, 2008 That will not make any difference the ON clause is used for certain types of joins suck as LEFT, RIGHT, INNER etc. What will slow the query down is if there is no index on lets say forum_id Quote Link to comment https://forums.phpfreaks.com/topic/116895-possible-methods-of-optimzing-this-i-dare-you/#findComment-601781 Share on other sites More sharing options...
samshel Posted July 29, 2008 Share Posted July 29, 2008 agree but that will make a big difference if forum_id has index, and i think it should have index as a foriegn key. but i cannot gaurantee how slow/fast it will be..may be it wont make any difference ...but optimization is about trying things which have chance of working and this certainly has.... Quote Link to comment https://forums.phpfreaks.com/topic/116895-possible-methods-of-optimzing-this-i-dare-you/#findComment-602348 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.