Page 1 of 1
Number of posts on forum
Posted: Thu Jul 14, 2005 3:00 am
by wocdam
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?
Posted: Thu Jul 14, 2005 3:16 am
by Chris Corbyn
Why search 20 times?
Code: Select all
SELECT COUNT (*) FROM `table` WHERE `username`='$username'
Posted: Thu Jul 14, 2005 4:10 am
by wocdam
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.
Posted: Thu Jul 14, 2005 4:17 am
by Chris Corbyn
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
