douba6365 2014-04-30 06:53 采纳率: 100%
浏览 29
已采纳

mongoDB索引结构

I have put Index on mongoDB.

when I ensureIndex using php it put 1 as NumberLong(1) .

I want to know:

  1. will this Indexing work or not. If not
  2. how to remove this NumberLong(1)

Code:

"0": {
    "v" : 1,
    "key" : {
        "telNum" : NumberLong(1),
        "requestID" : NumberLong(1)
    },
    "ns" : "database.collections",
    "background" : true,
    "name" : "tel_req"
  }
  • 写回答

1条回答 默认 最新

  • doxzrb8721 2014-04-30 07:08
    关注

    Yes, the index will still work.

    This is due to a change in the way that the PHP driver works ( https://jira.mongodb.org/browse/PHP-955 ).

    I will come out immediately and say that it is not advised to remove it. That NumberLong object supports throwing in 64bit integers by default so it is extremely useful to have the defaults in the new PHP driver on by default and to treat NumberLong as the new generic number object.

    However, to go into this a bit more and explain to you what's happening, there is this runtime configuration option called native_long: http://www.php.net/manual/en/mongo.configuration.php#ini.mongo.native-long which essentially allows MongoDB to store 64bit numbers by storing them into NumberLong objects. In PHP it would automatically convert to int data type and back again, making this transparent to the end user.

    If you have this turned off MongoDB can only store 32bit integers.

    This option used to be off by default but now it is on, that is why you are seeing this behaviour.

    You can turn it off in the PHP configuration to remove the NumberLongs

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 求数学坐标画圆以及直线的算法
  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决