944,201 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Feb 17th, 2007
0

Speed of member profiles

Expand Post »
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.
Similar Threads
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 163
The Queen of DaniWeb
cscgal is offline Offline
13,646 posts
since Feb 2002
Feb 17th, 2007
0

Re: Speed of member profiles

The speed of finding unanswered threads has also been rectified, unfortunately at the cost of showing the results as threads instead of as posts.
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 163
The Queen of DaniWeb
cscgal is offline Offline
13,646 posts
since Feb 2002
Feb 17th, 2007
0

Re: Speed of member profiles

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.
Super Moderator
Featured Poster
Reputation Points: 3244
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,873 posts
since Jun 2006
Feb 17th, 2007
0

Re: Speed of member profiles

Neither, actually. I had an SQL statement of the type:
sql Syntax (Toggle Plain Text)
  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.
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 163
The Queen of DaniWeb
cscgal is offline Offline
13,646 posts
since Feb 2002
Feb 17th, 2007
0

Re: Speed of member profiles

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...
Super Moderator
Featured Poster
Reputation Points: 3244
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,873 posts
since Jun 2006
Feb 17th, 2007
0

Re: Speed of member profiles

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.
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 163
The Queen of DaniWeb
cscgal is offline Offline
13,646 posts
since Feb 2002
Feb 17th, 2007
0

Re: Speed of member profiles

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 ?
Super Moderator
Featured Poster
Reputation Points: 3244
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,873 posts
since Jun 2006
Feb 17th, 2007
0

Re: Speed of member profiles

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?
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 163
The Queen of DaniWeb
cscgal is offline Offline
13,646 posts
since Feb 2002
Feb 17th, 2007
0

Re: Speed of member profiles

Click to Expand / Collapse  Quote originally posted by cscgal ...
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:
sql Syntax (Toggle Plain Text)
  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....

Quote ...
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.
Super Moderator
Featured Poster
Reputation Points: 3244
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,873 posts
since Jun 2006
Feb 17th, 2007
0

Re: Speed of member profiles

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%).
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 163
The Queen of DaniWeb
cscgal is offline Offline
13,646 posts
since Feb 2002

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in DaniWeb Community Feedback Forum Timeline: New Quick Reply
Next Thread in DaniWeb Community Feedback Forum Timeline: RSS Feeds





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC