Speed of member profiles

Reply

Join Date: Feb 2002
Posts: 12,039
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 127
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is online now Online
The Queen of DaniWeb

Speed of member profiles

 
0
  #1
Feb 17th, 2007
I have fixed the bug that was causing the ridiculous slowdown when viewing member profiles. It turns out that a particular WHERE clause in one of the queries was slowing things down too much, and after catching the culpreit, I was able to perform the query in PHP instead.
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,039
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 127
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is online now Online
The Queen of DaniWeb

Re: Speed of member profiles

 
0
  #2
Feb 17th, 2007
The speed of finding unanswered threads has also been rectified, unfortunately at the cost of showing the results as threads instead of as posts.
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,609
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 464
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Speed of member profiles

 
0
  #3
Feb 17th, 2007
Hmm.. so was it the number of round trips made to the database or a logic problem ?
Last edited by ~s.o.s~; Feb 17th, 2007 at 12:51 pm.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,039
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 127
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is online now Online
The Queen of DaniWeb

Re: Speed of member profiles

 
0
  #4
Feb 17th, 2007
Neither, actually. I had an SQL statement of the type:
  1. SELECT * FROM table
  2. WHERE
  3. COLUMN <> 123
  4. AND FIND_IN_SET(COLUMN, $php_array)
For whatever reason, it was taking a ridiculously long amount of time, despite having a MySQL index on the table column. So what I went and did was remove the first WHERE clause and instead sanitized the $php_array array to never include the element 123 before the sql query even runs. (I needed $php_array to include element 123 elsewhere in the script except for this particular SQL query which is why I did it that way to begin with.)
Last edited by cscgal; Feb 17th, 2007 at 1:37 pm.
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,609
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 464
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Speed of member profiles

 
0
  #5
Feb 17th, 2007
Okay so it was like 'performing operations which should never have been perfomed by the sql' sort of thing.

BTW indexing doesn't account for bad code you know...
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,039
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 127
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is online now Online
The Queen of DaniWeb

Re: Speed of member profiles

 
0
  #6
Feb 17th, 2007
Don't pick on me MySQL had to examine COLUMN anyways. It's not my fault it did a brute force search on all of the rows twice just because I wanted to compare COLUMN against a variable and an array.
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,609
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 464
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Speed of member profiles

 
0
  #7
Feb 17th, 2007
I certainly don't think it would be traversing the table twice, but I guess you know your tools the best.

BTW why not just use a simple IN clause ?
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,039
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 127
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is online now Online
The Queen of DaniWeb

Re: Speed of member profiles

 
0
  #8
Feb 17th, 2007
I'm thinking it would traverse all rows eliminating those where column is 123, and then go back on all of the others and check whether the value of column is in the array, so essentially that's going over nearly everything twice, no?

Well I did use a FIND_IN_SET() clause?
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,609
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 464
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Speed of member profiles

 
0
  #9
Feb 17th, 2007
Originally Posted by cscgal View Post
I'm thinking it would traverse all rows eliminating those where column is 123, and then go back on all of the others and check whether the value of column is in the array, so essentially that's going over nearly everything twice, no?
So you mean to say that every condition put in the WHERE clause results in a full table scan.. ? Atleast not in Oracle.

So if I were to use:
  1. SELECT * FROM Emp
  2. WHERE (emp_name LIKE '%Dani%') AND
  3. (emp_id IN (1, 2, 3, 4, 5)) AND
  4. (sal > 10000) ;
would this query scan entire table containing millions of records thrice ? Logically, don't think so....

Well I did use a FIND_IN_SET() clause?
Is there no simple IN clause in MySQL ? Something like the one written by me in the above snippet ?
Last edited by ~s.o.s~; Feb 17th, 2007 at 11:09 pm.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,039
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 127
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is online now Online
The Queen of DaniWeb

Re: Speed of member profiles

 
0
  #10
Feb 17th, 2007
FIND_IN_SET() appears to be similar to your IN() clause. However, you have to understand that this whole query is meant to determine which a member's favorite forums are and other members interested in the same forums. Therefore, we're searching 300,000+ rows first to see if one column isn't equal to a certain value (cuts out about 10%) and then seeing if the column value is in an array (searching the remaining 90%).
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/daniweb
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the DaniWeb Community Feedback Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC