Jump to content

Recommended Posts

Queries Used
SELECT id, member_id, running_time, location FROM ibf_sessions WHERE id='47170dea24fdae77b597246cbed5b084' and ip_address='127.0.0.1' SELECT moderator.mid as is_mod, m.mediate_msg, moderator.allow_warn, m.id, m.name, m.last_post, m.last_visit, m.mgroup, m.password, m.restrict_post, m.view_sigs, m.view_avs, m.view_pop, m.view_img,m.view_orb, m.auto_track, m.mod_posts, m.language, m.new_msg, m.show_popup, m.msg_total, m.dst_in_use, time_offset, m.points, m.desktop, m.skinstyle, m.org_perm_id, m.temp_ban, g.* FROM ibf_members m LEFT JOIN ibf_groups g ON (g.g_id=m.mgroup) LEFT JOIN ibf_moderators moderator ON (moderator.member_id=m.id OR moderator.group_id=m.mgroup ) WHERE m.id=1 UPDATE ibf_sessions SET member_name='monkuar',member_id='1',member_group='4',in_forum='0',in_topic='0',in_game='0|',login_type='0',running_time='1251381362',location='clan,,' WHERE id='47170dea24fdae77b597246cbed5b084' SELECT s.*, t.template FROM ibf_skins s LEFT JOIN ibf_templates t ON (t.tmid=s.tmpl_id) WHERE s.default_set=1 SELECT * FROM ibf_tcusergroups ORDER BY 'name' SELECT * FROM ibf_tcug_validate WHERE mid=1 AND tcugid=1 SELECT id,name,desktop FROM ibf_members WHERE id=1 AND (clanname LIKE '24-7GT' OR clanname LIKE '%,24-7GT' OR clanname LIKE '24-7GT,%' OR clanname LIKE '%,24-7GT,%') SELECT desktop FROM ibf_members WHERE id IN (1) LIMIT 0,3 SELECT name,id,desktop FROM ibf_members WHERE id IN (1) LIMIT 0,3 SELECT COUNT(*) as total FROM ibf_members WHERE clanid = '1' SELECT * FROM ibf_tcug_validate WHERE mid=1 AND tcugid=108 SELECT id,name,desktop FROM ibf_members WHERE id=1 AND (clanname LIKE 'Instinct' OR clanname LIKE '%,Instinct' OR clanname LIKE 'Instinct,%' OR clanname LIKE '%,Instinct,%') SELECT desktop FROM ibf_members WHERE id IN (2) LIMIT 0,3 SELECT name,id,desktop FROM ibf_members WHERE id IN (2) LIMIT 0,3 SELECT COUNT(*) as total FROM ibf_members WHERE clanid = '108' SELECT * FROM ibf_tcug_validate WHERE mid=1 AND tcugid=109 SELECT id,name,desktop FROM ibf_members WHERE id=1 AND (clanname LIKE 'Empire' OR clanname LIKE '%,Empire' OR clanname LIKE 'Empire,%' OR clanname LIKE '%,Empire,%') SELECT desktop FROM ibf_members WHERE id IN (5) LIMIT 0,3 SELECT name,id,desktop FROM ibf_members WHERE id IN (5) LIMIT 0,3 SELECT COUNT(*) as total FROM ibf_members WHERE clanid = '109' SELECT * FROM ibf_tcug_validate WHERE mid=1 AND tcugid=110 SELECT id,name,desktop FROM ibf_members WHERE id=1 AND (clanname LIKE '1111' OR clanname LIKE '%,1111' OR clanname LIKE '1111,%' OR clanname LIKE '%,1111,%') SELECT desktop FROM ibf_members WHERE id IN (10) LIMIT 0,3 SELECT name,id,desktop FROM ibf_members WHERE id IN (10) LIMIT 0,3 SELECT COUNT(*) as total FROM ibf_members WHERE clanid = '110' SELECT * FROM ibf_tcug_validate WHERE mid=1 AND tcugid=111 SELECT id,name,desktop FROM ibf_members WHERE id=1 AND (clanname LIKE 'bitch' OR clanname LIKE '%,bitch' OR clanname LIKE 'bitch,%' OR clanname LIKE '%,bitch,%') SELECT desktop FROM ibf_members WHERE id IN (12) LIMIT 0,3 SELECT name,id,desktop FROM ibf_members WHERE id IN (12) LIMIT 0,3 SELECT COUNT(*) as total FROM ibf_members WHERE clanid = '111' SELECT * FROM ibf_tcug_validate WHERE mid=1 AND tcugid=112 SELECT id,name,desktop FROM ibf_members WHERE id=1 AND (clanname LIKE 'Panda Guild' OR clanname LIKE '%,Panda Guild' OR clanname LIKE 'Panda Guild,%' OR clanname LIKE '%,Panda Guild,%') SELECT desktop FROM ibf_members WHERE id IN (92) LIMIT 0,3 SELECT name,id,desktop FROM ibf_members WHERE id IN (92) LIMIT 0,3 SELECT COUNT(*) as total FROM ibf_members WHERE clanid = '112' SELECT * FROM ibf_tcug_validate WHERE mid=1 AND tcugid=113 SELECT id,name,desktop FROM ibf_members WHERE id=1 AND (clanname LIKE 'Off Topic Inc.' OR clanname LIKE '%,Off Topic Inc.' OR clanname LIKE 'Off Topic Inc.,%' OR clanname LIKE '%,Off Topic Inc.,%') SELECT desktop FROM ibf_members WHERE id IN (35) LIMIT 0,3 SELECT name,id,desktop FROM ibf_members WHERE id IN (35) LIMIT 0,3 SELECT COUNT(*) as total FROM ibf_members WHERE clanid = '113' SELECT clan_cost FROM ibf_clan_settings

 

 

MY CODE:

 

$outer=$DB->query("SELECT * FROM ibf_tcusergroups ORDER BY 'name'");
		$this->output.=$this->html->show_start();

		if($ibforums->member['id'] == 0)
		{
			$std->Error( array( 'LEVEL' => 1, 'MSG' => 'ug_no_access' ) );
		}

		while($row=$DB->fetch_row($outer)) {


			$r_arr=explode(",",$row['mod_id']);
			$mod = (in_array($ibforums->member['id'],$r_arr) or $ibforums->member['mgroup']==$ibforums->vars['admin_group']) ? 1:0;
			$DB->query("SELECT * FROM ibf_tcug_validate WHERE mid={$ibforums->member['id']} AND tcugid={$row['tcugid']}");

			$valida=$DB->get_num_rows();
			$DB->query("SELECT id,name,desktop FROM ibf_members WHERE id={$ibforums->member['id']} AND ".
					"(clanname LIKE '".$row['name']."' OR clanname LIKE '%,".$row['name']."' OR ".

					"clanname LIKE '".$row['name'].",%' OR clanname LIKE '%,".$row['name'].",%')");

			$unjoin=$DB->get_num_rows();
			$row['made']      = $std->get_date( $row['made'], 'JOINED' );




			//Leader newman Mod~
			$DB->query("SELECT desktop FROM ibf_members WHERE id IN ({$row['mod_id']}) LIMIT 0,3");

		$row['desktop']="";while($rw=$DB->fetch_row()) {$row['desktop'].=$rw['desktop']."";} $row['mod_name']=substr($row['mod_name'],0,-1);


			//Leader newman Mod~
			$DB->query("SELECT name,id,desktop FROM ibf_members WHERE id IN ({$row['mod_id']}) LIMIT 0,3");

		$row['mod_name']="";while($rw=$DB->fetch_row()) {$row['mod_name'].=$rw['name'].",";} $row['mod_name']=substr($row['mod_name'],0,-1);


			$DB->query("SELECT COUNT(*) as total FROM ibf_members WHERE clanid = '{$row['tcugid']}'");
			$t = $DB->fetch_row();

 

 

Those small query's wont hurt that much right :(

??

OR should I try to inner join or do the m.fieldname as something which i have no idea how to do..

 

 

Link to comment
https://forums.phpfreaks.com/topic/172129-will-this-hurt/
Share on other sites

You should join tables to reduce the number of queries. You have 5 queries within the loop of the result of an initial query.

i.e. If the first query returned 500 records then that script would be running 1+(500*5) queries. 2501 queries in total. Crazy.

Link to comment
https://forums.phpfreaks.com/topic/172129-will-this-hurt/#findComment-907571
Share on other sites

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.