Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-1938

Pasting large amounts of text is very slow

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: CLI Module
    • None
    • Environment:
      OS:
      node.js / npm versions:
      Additional info:
    • 2
    • Developer Tools

      report from Ciprian Tibulca here https://mongodb.slack.com/archives/CUHC9R8J0/p1733416866347769

      (copy/pasting for when the slack link dies)

      hey team :wave:, I have a question about the recommended way to run a very large command (where the queryVector is ~20KB) in mongosh.

      copy-pasting the command directly takes a few minutes, which I assume is due to the formatting mongosh attempts to apply.

      I also tried using an external editor (vi), where pasting the command is relatively quick, but after exiting the editor, mongosh still takes just as long (minutes) to print, format and execute the command.

      is creating a file with the command and loading it into mongosh the only way to make this process faster?

      e.g.:
      create vectorSearchPipeline.js: const results = db.embedded_movies.aggregate([...])
      in mongosh: load("vectorSearchPipeline.js"), then print(results)

      (mongosh <uri> vectorSearchPipeline.js is not an option, as mongosh process is started by the AtlasCLI atlas deployments connect and not directly by the customer)


      I had one here https://mongodb.slack.com/archives/GJ2CBBY86/p1710950176769949

      The file / code example is already gone, but it was also $vectorSearch related.

      Definitely the syntax hilighting, doesn't happen in non-repl mode.


      Also this case reported by Gaurab here https://mongodb.slack.com/archives/GJ2CBBY86/p1712068269420299

      (copy/pasting again)

      Got this feedback from the field team:

      As a developer or DBA, it would be nice to create an agg pipeline in Compass or in my IDE, with comments, and then be able to c/p into mongosh with proper formatting and the ability to execute it. As of today, attempting to do this will not work.
      I tried pasting an agg with comments from vs code to mongosh - it works but right after use(''); , mongosh seems to also print the bottom half of the pasted code. Overall the repl does execute and output the right things though.

      Code sample there is just:

      use('taxi_support_tool');
      db.trips.aggregate(
          [
              {
                $geoNear: {
                  near: {
                    type: "Point",
                    coordinates: [-113.5384, 42.8802], // pick coordinates of the ride that's being disputed
                  },
                  distanceField: "dist.calculated",
                  maxDistance: 500, // value in meters (our own criteria)
                  query: {
                    trip_status: "completed",
                  },
                  spherical: true,
                },
              },
              {
                $match: {
                  // `total_duration` is in minutes, 97 ± 10 minutes (our own criteria)
                  total_duration: {
                    $gte: 87,
                    $lte: 107,
                  },
                  // similar distance is within a 2-mile window, 16.77 ± 2 miles (our own criteria)
                  actual_distance: {
                    $gte: 14.77,
                    $lte: 18.77,
                  }, 
                },
              },
              {
                $group: {
                  _id: null,
                  avgFare: {
                    $avg: "$total_fare",
                  },
                },
              },
            ]
      );  
      

      Note that this is not a large amount of text by any stretch.


      Another one by Ciprian again https://mongodb.slack.com/archives/C05EDE1CW7J/p1727111426756869

      Copy/Pasting:

      do we have a recommended way to run vectorSearch queries from mongosh?
      while reviewing existing public docs, I tried the example here https://www.mongodb.com/docs/atlas/cli/current/atlas-cli-deploy-fts/#run-an-example-query.-3 and copy/pasting is painfully slow (query is about 24 KB)
      a much faster approach (but not sure if recommended) is:
      save the query in a js file (const runVectorSearchQueryExample = () => db.embedded_movies.aggregate([...]))
      in mongsh load("vectorSearchQueryExample.js")
      then runVectorSearchQueryExample()

            Assignee:
            Unassigned Unassigned
            Reporter:
            leroux.bodenstein@mongodb.com Le Roux Bodenstein
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: