Hi,
I run a website with a custom forum and i would like to have the number of posts made by that user shown under his name, the problem is i have a user database of over 100 000, would it be a good idea preformance wise to search that databaese 20 times on each forum pageload or does anybody know an alternative way of doing this?
Number of posts on forum
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Why search 20 times?
Code: Select all
SELECT COUNT (*) FROM `table` WHERE `username`='$username'Because i show 20 messages per page.
The code you just gave me would increase the queries, i have the forum devided into several tables, so that would require me to do even more queries. i have the number of posts made stored in the user table. the intention was to grab the number from there. and i forgot to add something i also need to grab the signiature from the user table. so the question is, is preformance wise the best way to just grab it from the usertable each time or can anyone shed some light on other possible methods.
The code you just gave me would increase the queries, i have the forum devided into several tables, so that would require me to do even more queries. i have the number of posts made stored in the user table. the intention was to grab the number from there. and i forgot to add something i also need to grab the signiature from the user table. so the question is, is preformance wise the best way to just grab it from the usertable each time or can anyone shed some light on other possible methods.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
For each member on that page you will need to run the query again for that user. It shouldn't be a problem, alternatively, store the post count in the DB everytime a post is made or deleted. I think phpBB does just this. That way you can run a single query to select the post count for each memeber shown on the page 