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 opencv 无法读取视频
  • ¥15 用matlab 实现通信仿真
  • ¥15 按键修改电子时钟,C51单片机
  • ¥60 Java中实现如何实现张量类,并用于图像处理(不运用其他科学计算库和图像处理库))
  • ¥20 5037端口被adb自己占了
  • ¥15 python:excel数据写入多个对应word文档
  • ¥60 全一数分解素因子和素数循环节位数
  • ¥15 ffmpeg如何安装到虚拟环境
  • ¥188 寻找能做王者评分提取的
  • ¥15 matlab用simulink求解一个二阶微分方程,要求截图