zoukankan      html  css  js  c++  java
  • Index Data

    We would have a list of documents sorted by user
    and then subsorted by date, so it would look something like the following:
    User 123 on March 13, 2010
    User 123 on March 12, 2010
    User 123 on March 11, 2010
    User 123 on March 5, 2010
    User 123 on March 4, 2010
    User 124 on March 12, 2010
    User 124 on March 11, 2010
    ...
    This looks fine at this scale, but imagine if the application has millions of users who
    have dozens of status updates per day. If the index entries for each user’s status messages
    take up a page’s worth of  space on disk,  then  for every “latest  statuses” query,  the
    database will have to load a different page into memory. This will be very slow if the
    site becomes popular enough that not all of the index fits into memory.
    If we  flip  the  index order  to {date : -1, user : 1},  the database can keep  the  last
    couple days of the index in memory, swap less, and thus query for the latest statuses
    for any user much more quickly.

      1. What are the queries you are doing? Some of these keys will need to be indexed.
      2. What is the correct direction for each key?
      3. How is this going to scale? Is there a different ordering of keys that would keep
        more of the frequently used portions of the index in memory?
    If you can answer these questions, you are ready to index your data.

  • 相关阅读:
    莫队模板
    CF600E Lomsat gelral
    JZOJ 捕老鼠
    JZOJ 4896. 【NOIP2016提高A组集训第16场11.15】兔子
    JZOJ 4895【NOIP2016提高A组集训第16场11.15】三部曲
    双端队列xLIS问题
    最大K段和
    你真的了解ES6的promise吗?
    JS对象和数组深浅拷贝总结②
    当前页码删除唯一数据后加载前一页内容
  • 原文地址:https://www.cnblogs.com/xgw2004058/p/2189510.html
Copyright © 2011-2022 走看看