sql - Count million users from DB realtime? -


what's efficient way select count(*) db in order count registered users , create counter realtime (or realtime)? dont want run query every second (on mln users)..was thinking running each hour , calculate new users , create estimated counter.. things tracking visitors won't work, bc come lots of sites, have use users database.. suggestions?

what db? both sql server , oracle instance can maintain count in indexed (materialized) view. eg on sql server:

create view metric schema binding select count_big(*) registeredusercount  dbo.users ...;  create clustered index cdxmetric on metric(registeredusercount); 

the engine maintain count accurate you, see improving performance sql server 2008 indexed views:

select registeredusercount  dbo.metric (noexpand); 

furthermore, can cache result , automatic invalidation, see linqtocache.

if on mysql backed system, best way count once, keep count in memcached , update when register new user.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -