Jump to content


Photo

Advanced Coding Issue (Speed Related)


  • Please log in to reply
4 replies to this topic

#1 mcmuney

mcmuney
  • Members
  • PipPipPip
  • Advanced Member
  • 358 posts

Posted 05 July 2006 - 11:04 PM

Overview: I'm trying to figure out what's causing a specific function to be EXTREMELY SLOW. I have a beta online community site with approximately 800 members. On the browse page, there's the option to browse only users with photos, which is the default OR to browse for all users, by checking "Include users without photos" checkbox.
Additional Info: Of the 800 members, roughly 400 have photos.

PROBLEM: The default search (photos only - 400 results) is fairly fast, averages < .2 secs on DSL/Cable. However, when searched to include all results (about 800 results), twice as the default search, it averages about 13 secs on same connection. At the very max, it should take double the time < .4 secs.

View Full Code: http://rateometer.com/test.txt
Test Problem: http://rateometer.co...rowse_users.php (to test, just click on this link and click the Search button, the search time is displayed at the bottom/left of the page. Now, check the "Include users with photos" checkbox and attempt the same search and note the time difference)

Any help on identifying the root of the problem will be greatly appreciated.

#2 Travis Estill

Travis Estill
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 06 July 2006 - 12:13 AM

Are the related SQL image fields indexed?

Travis
Freelance Web Developer with a focus on PHP/MySQL

Angel-Stones.com
ClanQ3.com

#3 mcmuney

mcmuney
  • Members
  • PipPipPip
  • Advanced Member
  • 358 posts

Posted 06 July 2006 - 12:36 AM

Yes, all images are cropped and indexed into smaller sized thumbs. But this shouldn't be the issue, because the search results are fast by default (with member photos). When it includes members WITHOUT photos, the search time drags, this should only add 2 no photo images (one for each gender).

#4 Travis Estill

Travis Estill
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 06 July 2006 - 04:38 AM

Well, I was referring to your database query. Specifically these lines:

if($Photos == "")
   {
   $search_q= $search_q." and m_img.sci_main=1 and m.scm_mem_id = m_img.scm_mem_id";
   $search_q_num.=" and m_img.sci_main=1 and m.scm_mem_id = m_img.scm_mem_id";
   }

Can you explain what's going on here? It looks like extra restrictions are being placed on the query if the user includes members without photos in their search. But it seems like only the opposite would make sense.
Freelance Web Developer with a focus on PHP/MySQL

Angel-Stones.com
ClanQ3.com

#5 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 06 July 2006 - 04:45 AM

a) you should not use the global variables for posted items that are a product of register_globals being set to ON. 

b) you should not use the GET method in your form, although i see you've made some kind of effort in security by using a token..

c) you have made no effort to sanitize any of your variables, just inserting them directly into your query, far as i can tell, unless your class method that you send your query to does it

d) i see this:
if($Photos == "")
			{
				$search_q= $search_q." and m_img.sci_main=1 and m.scm_mem_id = m_img.scm_mem_id";
				$search_q_num.=" and m_img.sci_main=1 and m.scm_mem_id = m_img.scm_mem_id";
			}
maybe i'm blind but I don't see an alternative for if there IS a value...

e) you have this big block of if's that should be condensed to a switch statement

f) can you please echo out and post both search query examples

Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users