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

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

报告相同问题?

悬赏问题

  • ¥15 如何实验stm32主通道和互补通道独立输出
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题