Jump to content

Recommended Posts

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.

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

 

 

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.