首页 > php统计七日留存率

php统计七日留存率

数据库大概有5万多登录详情数据,怎么查表统计七日留存率效率比较高?


5万多怎么弄都行,直接 PHP 数组处理也不会消耗太多内存。
再多可以考虑用 memcache 或者 redis 存储中间结果。


组合个注册数组键值为 datetime 年月日格式的;
例如: 2016-08-11

$arr = [
    '2016-08-11' => [2,3,5,6,111,333,23],//存储当天注册的用户id
    '2016-08-12' => [],
    ....
]

查2016-08-11用户的留存率

 select count(*) from operation_log where client_id in() and login_time bewteen 1 and 2

2016-08-17的登录数/2016-08-11的登录用户数 = 留存率

【热门文章】
【热门文章】