Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-1820

Max index name length is 125 characters (not 128)

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Trivial - P5 Trivial - P5
    • 01112017-cleanup
    • Affects Version/s: None
    • Component/s: manual
    • Labels:
      None

      In accordance to documentation http://docs.mongodb.org/manual/reference/limits/

      Index Name Length
      The names of indexes, including their namespace (i.e database and collection name) cannot be longer than 128 characters.

      ...

      Max index name length is 128 but real limitation is 125 characters.

      Steps to reproduce
      Please use mongo shell to reproduce it:

      > use test56789;
      switched to db test56789
      > db.createCollection("coll567890");
      { "ok" : 1 }
      > db.co
      db.coll567890     db.commandHelp(   db.constructor    db.copyDatabase(
      > db.coll567890.getIndexes();
      [
              {
                      "v" : 1,
                      "key" : {
                              "_id" : 1
                      },
                      "ns" : "test56789.coll567890",
                      "name" : "_id_"
              }
      ]
      > db.coll567890.ensureIndex({"a" : 1},{"name" : "index6789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678"});
      ns name too long, max size is 128
      

      So lets calculate index name length with their alias:
      <database.name> + <collection.name> + <index.name> = 9 + 1 (dot) + 10 + 108 = 128

      Expected result:

      • update documentation - set 125 characters as max index name length.

            Assignee:
            zack.brown@10gen.com Zack Brown
            Reporter:
            nvolynets Nazar Volynets
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              10 years, 33 weeks, 2 days ago