推荐工具
› RoboMongo
推荐书目
› 50 Tips and Tricks for MongoDB Developers
Related Blogs
› Snail in a Turtleneck
eggegg
V2EX  ›  MongoDB

一个 collection 有 3500 万条数据,我想操作 distinct 某字段,请问正确姿势!

  •  
  •   eggegg · Jun 15, 2015 · 5896 views
    This topic created in 4159 days ago, the information mentioned may be changed or developed.

    如题试了下,非常慢,请问下有没有更好的姿势!

    9 replies  •  2015-06-15 22:28:51 +08:00
    yangmls
    yangmls
    Jun 15, 2015
    1
    有索引没?如果有,请检查

    1. mongo 版本,升级到 mongo 3.0,版本 2.X 经常有 index 无法命中的问题

    2. 有没有 query,query 是否有 index

    3. explain 一下

    4. log 文件,是否提示 low query

    5. 加 hint,不一定可行,这玩意在 find 之外的行为有点诡异
    yangmls
    yangmls
    Jun 15, 2015
    2
    *slow
    dai269619118
    dai269619118
    Jun 15, 2015
    3
    这问题问的...服
    d0evi1
    d0evi1
    Jun 15, 2015
    4
    条件允许的话,丢到hadoop集群上跑一下.
    Had
    Had
    PRO
    Jun 15, 2015
    5
    @yangmls 是2.6行为诡异吧,2.4感觉还是挺不错的...
    我遇到实际运行时和explain的index选择不一样... 主动去getPlanCache().clear()还没有办法清除cache.
    yangmls
    yangmls
    Jun 15, 2015
    6
    @Had 2.6 bug 多得逆天,别提了,都是泪

    我们有一个 findAndModify 的玩意,用在队列上,明明 explain 正常,但就是无法命中缓存,结果就是一天能跑出 15个G 的日志文件。。。。。
    yangmls
    yangmls
    Jun 15, 2015
    7
    *命中索引
    Had
    Had
    PRO
    Jun 15, 2015
    8
    @yangmls
    我和你一样... 但是还是在硬着头皮升级...
    能不能留个啥交流一下,已经折磨了我们许久了,或许能有什么可以参考的...
    yangmls
    yangmls
    Jun 15, 2015
    9
    @Had 我们已经升完 mongo 了

    扣扣 yangmls#live.cn
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1751 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 17:29 · PVG 01:29 · LAX 09:29 · JFK 12:29
    ♥ Do have faith in what you're doing.