Use JSON.stringify() to serialize string in tojson()

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Fixed
    • Priority: Major - P3
    • 3.4.21, 3.6.13, 4.0.10, 4.1.11
    • Affects Version/s: None
    • Component/s: Shell
    • None
    • Fully Compatible
    • v4.0, v3.6, v3.4
    • Repl 2019-05-06
    • 50
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      Serializing long string is very slow in tojson(). Calling tojson() takes about 15 seconds for a 16MB long string.

       

      $ ./mongo --nodb
      MongoDB shell version v0.0.0
      > var start = Date.now(); tojson("x".repeat(16 * 1024 * 1024)); print(Date.now() - start)
      14320
      

            Assignee:
            Siyuan Zhou
            Reporter:
            Siyuan Zhou
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: