在线精品99_中国九九盗摄偷拍偷看_91免费版在线观看_91.app_91高清视频在线_99热最新网站

如何使用MySQL位图索引解决用户画像问题

124次阅读
没有评论

共计 4573 个字符,预计需要花费 12 分钟才能阅读完成。

这篇文章给大家分享的是有关如何使用 MySQL 位图索引解决用户画像问题的内容。丸趣 TV 小编觉得挺实用的,因此分享给大家做个参考,一起跟随丸趣 TV 小编过来看看吧。

每个 bigint 类型包括 60 个记录的位信息.

但是第 0 位表示第六十个记录的位

第 1 位至第 59 位表示第一至五十九的记录的位信息.

这样记录的位信息保存并不连续,

使用的时候还得把最右边的一位挪到最左边, 不好理解还非常麻烦, 性能也有损耗.

经过王工的改良,

使用如下 sql 替换,则保存的位信息就连续了

SELECT 
 CEIL(id / 60) g60,
 CEIL(id / 1200) g1200,
 age grouped,
 COUNT(*) total,
 BIT_OR(1   (if(MOD(id, 60)=0,60,MOD(id, 60)))) bitmap
 FROM
 o_huaxiang_big_0 o
 GROUP BY g1200 , g60 , age

创建位图索引的整体 SQL 如下

truncate table bitmap20_0;
insert into bitmap20_0 
select 
  o_huaxiang_big  table_name,
  umc_sex  column_name,
 ((g1200-1)*60)*20 min_id,
 ((g1200-1)*60)*20+1200 max_id,
 v2.*
from (
 select 
 g1200,
 grouped,
 sum(total) total, 
 ifnull(max(case when abs((g1200-1)*20-g60)=20 then bitmap else null end),0) c20,
 ifnull(max(case when abs((g1200-1)*20-g60)=19 then bitmap else null end),0) c19,
 ifnull(max(case when abs((g1200-1)*20-g60)=18 then bitmap else null end),0) c18,
 ifnull(max(case when abs((g1200-1)*20-g60)=17 then bitmap else null end),0) c17,
 ifnull(max(case when abs((g1200-1)*20-g60)=16 then bitmap else null end),0) c16,
 ifnull(max(case when abs((g1200-1)*20-g60)=15 then bitmap else null end),0) c15,
 ifnull(max(case when abs((g1200-1)*20-g60)=14 then bitmap else null end),0) c14,
 ifnull(max(case when abs((g1200-1)*20-g60)=13 then bitmap else null end),0) c13,
 ifnull(max(case when abs((g1200-1)*20-g60)=12 then bitmap else null end),0) c12,
 ifnull(max(case when abs((g1200-1)*20-g60)=11 then bitmap else null end),0) c11,
 ifnull(max(case when abs((g1200-1)*20-g60)=10 then bitmap else null end),0) c10,
 ifnull(max(case when abs((g1200-1)*20-g60)=9 then bitmap else null end),0) c9,
 ifnull(max(case when abs((g1200-1)*20-g60)=8 then bitmap else null end),0) c8,
 ifnull(max(case when abs((g1200-1)*20-g60)=7 then bitmap else null end),0) c7,
 ifnull(max(case when abs((g1200-1)*20-g60)=6 then bitmap else null end),0) c6,
 ifnull(max(case when abs((g1200-1)*20-g60)=5 then bitmap else null end),0) c5,
 ifnull(max(case when abs((g1200-1)*20-g60)=4 then bitmap else null end),0) c4,
 ifnull(max(case when abs((g1200-1)*20-g60)=3 then bitmap else null end),0) c3,
 ifnull(max(case when abs((g1200-1)*20-g60)=2 then bitmap else null end),0) c2,
 ifnull(max(case when abs((g1200-1)*20-g60)=1 then bitmap else null end),0) c1
 from (
 SELECT 
 CEIL(id / 60) g60,
 CEIL(id / 1200) g1200,
 umc_sex grouped,
 COUNT(*) total,
 BIT_OR(1   (if(MOD(id, 60)=0,60,MOD(id, 60)))) bitmap
 FROM
 o_huaxiang_big_0 o
 GROUP BY g1200 , g60 , umc_sex
 ) v1 group by g1200,grouped
) v2;
 
insert into bitmap20_0 
select 
  o_huaxiang_big  table_name,
  age  column_name,
 ((g1200-1)*60)*20 min_id,
 ((g1200-1)*60)*20+1200 max_id,
 v2.*
from (
 select 
 g1200,
 grouped,
 sum(total) total, 
 ifnull(max(case when abs((g1200-1)*20-g60)=20 then bitmap else null end),0) c20,
 ifnull(max(case when abs((g1200-1)*20-g60)=19 then bitmap else null end),0) c19,
 ifnull(max(case when abs((g1200-1)*20-g60)=18 then bitmap else null end),0) c18,
 ifnull(max(case when abs((g1200-1)*20-g60)=17 then bitmap else null end),0) c17,
 ifnull(max(case when abs((g1200-1)*20-g60)=16 then bitmap else null end),0) c16,
 ifnull(max(case when abs((g1200-1)*20-g60)=15 then bitmap else null end),0) c15,
 ifnull(max(case when abs((g1200-1)*20-g60)=14 then bitmap else null end),0) c14,
 ifnull(max(case when abs((g1200-1)*20-g60)=13 then bitmap else null end),0) c13,
 ifnull(max(case when abs((g1200-1)*20-g60)=12 then bitmap else null end),0) c12,
 ifnull(max(case when abs((g1200-1)*20-g60)=11 then bitmap else null end),0) c11,
 ifnull(max(case when abs((g1200-1)*20-g60)=10 then bitmap else null end),0) c10,
 ifnull(max(case when abs((g1200-1)*20-g60)=9 then bitmap else null end),0) c9,
 ifnull(max(case when abs((g1200-1)*20-g60)=8 then bitmap else null end),0) c8,
 ifnull(max(case when abs((g1200-1)*20-g60)=7 then bitmap else null end),0) c7,
 ifnull(max(case when abs((g1200-1)*20-g60)=6 then bitmap else null end),0) c6,
 ifnull(max(case when abs((g1200-1)*20-g60)=5 then bitmap else null end),0) c5,
 ifnull(max(case when abs((g1200-1)*20-g60)=4 then bitmap else null end),0) c4,
 ifnull(max(case when abs((g1200-1)*20-g60)=3 then bitmap else null end),0) c3,
 ifnull(max(case when abs((g1200-1)*20-g60)=2 then bitmap else null end),0) c2,
 ifnull(max(case when abs((g1200-1)*20-g60)=1 then bitmap else null end),0) c1
 from (SELECT 
 CEIL(id / 60) g60,
 CEIL(id / 1200) g1200,
 age grouped,
 COUNT(*) total,
 BIT_OR(1   (if(MOD(id, 60)=0,60,MOD(id, 60)))) bitmap
 FROM
 o_huaxiang_big_0 o
 GROUP BY g1200 , g60 , age
 ) v1 group by g1200,grouped
) v2;

感谢各位的阅读!关于“如何使用 MySQL 位图索引解决用户画像问题”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-07-26发表,共计4573字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)
主站蜘蛛池模板: av鲁丝一区鲁丝二区鲁丝三区 | 无码男男做受g片在线观看视频 | 亚洲午夜久久影院 | 中日精品无码一本二本三本 | 美女视频黄是免费 | 欧美日韩精 | 精品人人妻人人澡人人爽牛牛 | 日韩国产精品99久久久久久 | jizz亚洲日本 | 欧美激情一区二区 | 亚洲图片 中文字幕 | 精品免费福利视频 | 大又大又粗又硬又爽少妇毛片 | 中文字幕在线播放视频 | 国产精品白浆一区二小说 | 久久成人国产精品免费 | 精品人妻少妇嫩草av无码专区 | 香蕉视频入口 | 婷婷丁香五月六月综合激情啪 | 日本一级特黄毛片免费视频9 | 日韩欧美亚洲乱码中文字幕 | 亚洲 自拍 中文字幕 在线 | 日本成年x片免费观看网站 日本成年人视频网站 | 欧美丰满熟妇aaaaa片 | 亚洲av成人www永久无码精品 | 最新99国产成人精品视频免费 | 99精品一区二区三区 | 亚洲综合成人网在线观看 | 色狠狠av老熟女 | 欧美日韩国产一区二区三区欧 | 免费能直接在线观看黄的视频 | 亚洲精品久久久久中文字幕二区 | 中文精品无码中文字幕无码专区 | 影音先锋男人的网站 | 亚洲日韩爆乳中文字幕欧美 | 成人性a激情免费视频 | 久久精品国产亚洲av麻豆小说 | 最新中文无码字字幕在线 | 国产日韩欧美亚洲综合首页 | 国产国拍亚洲精品mv在线观看 | 成年男女免费大片在线观看 |