Re: [PHP] Counting Online users, but not using a Session Table in MySQL

2011-01-28 Thread Jim Lucas
On 1/28/2011 11:23 AM, David Harkness wrote: > On Fri, Jan 28, 2011 at 11:03 AM, Marc Guay wrote: > >> If COUNTing is the heavy part, why not create a 'users_logged_in' >> field somewhere and increment it when someone logs in and decrement it >> when someone logs out? Then your query is just a s

Re: [PHP] Counting Online users, but not using a Session Table in MySQL

2011-01-28 Thread David Harkness
On Fri, Jan 28, 2011 at 11:03 AM, Marc Guay wrote: > If COUNTing is the heavy part, why not create a 'users_logged_in' > field somewhere and increment it when someone logs in and decrement it > when someone logs out? Then your query is just a straight SELECT. If this is like most web sites, us

Re: [PHP] Counting Online users, but not using a Session Table in MySQL

2011-01-28 Thread Marc Guay
> I'm looking for a faster way to count online users. COUNT(*) is time > consuming under MySQL. If COUNTing is the heavy part, why not create a 'users_logged_in' field somewhere and increment it when someone logs in and decrement it when someone logs out? Then your query is just a straight SELEC

Re: [PHP] Counting Online users, but not using a Session Table in MySQL

2011-01-28 Thread David Harkness
If you're using memcached already you could store the number in it and update it only when a user logs in/out. If no one is logging in/out, the number isn't changing. If your site is so popular that hundreds of users are logging in every second you might want to change the logic so that the proces

Re: [PHP] Counting Online users, but not using a Session Table in MySQL

2011-01-28 Thread AmirBehzad Eslami
Jim, I'm already using the solution you mentioned. The problem is about the performance. One solution is to increase the performance by using Memcached. But counting online users always requires a __new__fresh__ COUNT(*) query, even under Memcahched. Since the COUNT(*) result is very dynamic and

Re: [PHP] Counting Online users, but not using a Session Table in MySQL

2011-01-28 Thread Jim Lucas
On 1/28/2011 9:57 AM, AmirBehzad Eslami wrote: > Dear list, > > The common solution for counting online users is to store sessions in a Table. > I've created a Table in MySQL to acheive the result, but it seems this > solution > is a little heavy for such a simple task. > > Is there a better alt

Re: [PHP] Counting Online users, but not using a Session Table in MySQL

2011-01-28 Thread Fernando
How did you created the table? Can you count the Id's only? Wouldn't this just count the entries in the index? On 28/01/2011 12:57, AmirBehzad Eslami wrote: Dear list, The common solution for counting online users is to store sessions in a Table. I've created a Table in MySQL to acheive the