简体   繁体   中英

Performance based count for total number of users registered

What is the best way to keep track of the TOTAL NUMBER OF USERS REGISTERED in terms of performance?

select count(id) from user_table

OR

  • Create a table which stores number of users registered and every time a new user registers, increment the value by 1.

The total number of users registered will be displayed on the Admin Dashboard.

If there is any other way to do it, i would love to know.

The count exist to accomplish your request:

Select count(id) from user_table

If you create another table, at every new registration you need to alter the table and increment the value, costing one operation every time a user register.

Don't create another table for that.

Just do Select count(id) from user_table it's just fine

I have already commented on this but i think that posting it as an answer would fit better.

When it comes to performance, the first think one might think of is "Caching", you can simplay store the total number of users in a caching object "something like memcached " and read from it instead of database, when a new user registers you may reset the value of that object with the new one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM