当前位置:网站首页>11_ Redis_ Hyperloglog_ command
11_ Redis_ Hyperloglog_ command
2022-07-02 15:19:00 【Listen to the rain】
Hyperloglog
What is the cardinality ?
A{ 1,3,5,7,8,7 }
B{ 1,3,5,7,8 }
base ( Elements that don't repeat ) = 5, The error is acceptable !
brief introduction
Redis 2.8.9 The version is updated Hyperloglog data structure !
Redis Hyperloglog The algorithm of cardinality Statistics !
advantage : The memory occupied is fixed ,2^64 Different elements of Technology , Just waste 12KB Memory ! If you want to compare from the memory point of view Hyperloglog The preferred !
Web page UV( A person visits a website many times , But still count as a person ! ) 0.81% Error rate ! Statistics UV Mission , Negligible !
The traditional way ,set( Elements are not allowed to repeat ) Save the user's id, And then you can count set The number of elements in as a standard judgment !
This way, if you save a large number of users id, It will be more troublesome ! Our purpose is to count , Instead of saving users id;
127.0.0.1:6379> PFADD mykey a b c d e f g h i j k // Create the first set of elements
(integer) 1
127.0.0.1:6379> PFCOUNT mykey // Statistics mykey The cardinal number of elements
(integer) 11
127.0.0.1:6379> PFADD mykey2 i j k z d e // Create a second set of elements mykey2
(integer) 1
127.0.0.1:6379> PFCOUNT mykey2
(integer) 6
127.0.0.1:6379> PFMERGE mykey3 mykey mykey2 // Combine the two groups mykey mykey2 => mykey3 Combine
OK
127.0.0.1:6379> PFCOUNT mykey3 // Look at the number of unions !
(integer) 12
If fault tolerance is allowed , Then it must be possible to use Hyperloglog
If fault tolerance is not allowed , Just use set Or your own data type !
边栏推荐
- 10_Redis_geospatial_命令
- C语言实现N皇后问题
- GeoServer offline map service construction and layer Publishing
- MFC CString to char*
- The traversal methods of binary tree mainly include: first order traversal, middle order traversal, second order traversal, and hierarchical traversal. First order, middle order, and second order actu
- Mavn builds nexus private server
- C # delay, start the timer in the thread, and obtain the system time
- XML Configuration File
- 记一次报错解决经历依赖重复
- TiDB数据迁移场景综述
猜你喜欢
Introduction to C language -- array
学习使用php将时间戳转换为大写日期的方法代码示例
forEach的错误用法,你都学废了吗
基于RZ/G2L | OK-G2LD-C开发板存储读写速度与网络实测
MFC timer usage
XML Configuration File
Kibana basic operation
[development environment] install the visual studio community 2013 development environment (download the installation package of visual studio community 2013 with update 5 version)
编译原理课程实践——实现一个初等函数运算语言的解释器或编译器
06_ Stack and queue conversion
随机推荐
Dragonfly low code security tool platform development path
TiDB 环境与系统配置检查
TiDB数据迁移场景综述
Practice of compiling principle course -- implementing an interpreter or compiler of elementary function operation language
21_ Redis_ Analysis of redis cache penetration and avalanche
17_Redis_Redis发布订阅
IE 浏览器正式退休
做好抗“疫”之路的把关人——基于RK3568的红外热成像体温检测系统
871. Minimum refueling times: simple priority queue (heap) greedy question
如何对 TiDB 进行 TPC-C 测试
Application of CDN in game field
.NET Core 日志系统
Solution of Queen n problem
Mfc a dialog calls B dialog function and passes parameters
Tidb environment and system configuration check
Application and practice of Jenkins pipeline
11_Redis_Hyperloglog_命令
Have you learned the wrong usage of foreach
PHP method to get the index value of the array item with the largest key value in the array
07_ Hash