doddsey_65 Posted June 9, 2011 Share Posted June 9, 2011 i need to color the username of user to display which group they belong to on my forum. i do this by running a query which gets their group and joins the group table to get the color. I then return the link which is colored accordingly. However this means a query for every username that is displayed on the screen. I did this the same way on the old version of the forum and it seemed fine. My query count would stay at around 14 regardless of how many users were on screen. However in this new version i am getting around 25 queries because of this, most of them getting the color for every user. is there a better way to do this? Quote Link to comment https://forums.phpfreaks.com/topic/238886-link-and-color-username/ Share on other sites More sharing options...
mgoodman Posted June 9, 2011 Share Posted June 9, 2011 Well you're going to have to query for those 25 users eventually. Maybe you should try some simple caching for 5 or 10 minutes. I'm sure that the user list doesn't have to be completely accurate all the time, does it? You could do a simple file cache where you generate the HTML needed to display the user list and then save that in a file. Let's say you have something like 15 requests per second, if you do those 25 queries for each request then over the course of 10 minutes you've performed 15,000 queries. However if you queried the information and stored it in a cache for 10 minutes then you are down to 25 queries per 10 minutes. Quote Link to comment https://forums.phpfreaks.com/topic/238886-link-and-color-username/#findComment-1227477 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.