加入收藏 | 设为首页 | 会员中心 | 我要投稿 源码网 (https://www.900php.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

海量、多维数据让人抓狂?高效搜索方法看这里

发布时间:2019-09-16 22:47:06 所属栏目:MySql教程 来源:读芯术
导读:副标题#e# 人与世界万物的互动会产生大量的时空数据。那么,当我们需要随时调用过去的数据时,改怎么办?尤其是面对各种海量、多维度的数据库,如果没有高效的搜索方法,我们只能望洋兴叹、束手无策。 别担心,本文将用详细的代码,手把手来传授高效搜索法的

但是,可以同时使用这些索引吗? PostgreSQL为多个索引提供bitmapAnd及bitmapOr接口。它们可以组合多个索引,减少需要扫描的数据库数量。

  1. Heap, one square = one page:  
  2. +---------------------------------------------+  
  3. |c____u_____X___u___X_________u___cXcc______u_|  
  4. +---------------------------------------------+  
  5. Rows marked c match customers pkey condition.  
  6. Rows marked u match username condition.  
  7. Rows marked X match both conditions.  
  8. Bitmap scan from customers_pkey:  
  9. +---------------------------------------------+  
  10. |100000000001000000010000000000000111100000000| bitmap 1  
  11. +---------------------------------------------+  
  12. One bit per heap page, in the same order as the heap  
  13. Bits 1 when condition matches, 0 if not  
  14. Bitmap scan from ix_cust_username:  
  15. +---------------------------------------------+  
  16. |000001000001000100010000000001000010000000010| bitmap 2  
  17. +---------------------------------------------+  
  18. Once the bitmaps are created a bitwise AND is performed on them:  
  19. +---------------------------------------------+  
  20. |100000000001000000010000000000000111100000000| bitmap 1  
  21. |000001000001000100010000000001000010000000010| bitmap 2  
  22.  &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&  
  23. |000000000001000000010000000000000010000000000| Combined bitmap  
  24. +-----------+-------+--------------+----------+  
  25.  | | |  
  26.  v v v  
  27. Used to scan the heap only for matching pages:  
  28. +---------------------------------------------+  
  29. |___________X_______X______________X__________|  
  30. +---------------------------------------------+  
  31. The bitmap heap scan then seeks to the start of each page and reads the page:  
  32. +---------------------------------------------+  
  33. |___________X_______X______________X__________|  
  34. +---------------------------------------------+  
  35. seek------->^seek-->^seek--------->^  
  36.  | | |  
  37.  ------------------------  
  38.  only these pages read 

(编辑:源码网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读