• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

mysql and php question

Joined
Jun 26, 2006
Messages
37
i'm noticing some lag time on my site. i designed the forum myself so it's bound to have problems. switching to a third part forum isn't an option but i wont go into those reasons.

the problem here occurs when people view threads with many replies. i think i'm catching the lag time because the way i have it programmed is... I have it grab the thread then all the replies all at once, add the html then return them. My question is, would it really make that much difference if i changed the code to grab one reply at a time and return them after each individual reply is returned?

It doesn't seem to matter to much on the size of the thread because very long threads with no replies seem to load almost instantly, but if theres a large number of replies it starts to hurt the load time.

i'm open to any ideas or techniques the shave my load times.
 
I would suggest you try to benchmark your queries. Find out which one is taking up time. If you find one that seems to take up alot of time (multipled by the amount of times it's called per page), try to fiddle around with it and make it faster. For instance, a JOIN might help you get all the info from one query, it's taking 1 sec to get the reply, whereas 2 queries might only take 0.5 seconds.

Another thing you might want to try if you already haven't, is to limit the amount shown per page. Maybe display only 10 posts per thread/page, like what this forum does.
 
I would show a limited number of posts per page, and get all the replies in one go (use limit and offset). Shouldshow a bit of speedup, although visitors will ahve to click to go to the next page, but all other forums do this anyway, so its expected.
 
so i guess i should ask this, would grabbing 10 query items all at once be faster then grabbing 10 items individually? they would be select statments. I imagine all 10 at once would be faster, but thats what i'm doing now and i'm havin the problems, so i'm wondering if carrying so much data over is what is causing this?

i'm gonna do the benchmarks as well, i think thats a really good idea and i'm smacking my forehead for not thinking of it myself, lol
 
Sometimes 10 queries can be faster than 1 query with 10 items, but that all depends on the structure of the select. If it's just "SELECT 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 FROM table WHERE this = that", than yes that's faster than 10 individual selects.
 
GaryS128 said:
Sometimes 10 queries can be faster than 1 query with 10 items,
If this is the case, I'd seriously wonder what was wrong with the data model, query, or index structure.
 
I'd expect the one query to be faster, I too would be worried about it if it wasnt, at least if there was no obvious reason why.
 
Back
Top