Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Fast writing to mongodb make Application not responding
QtWS25 Last Chance

Fast writing to mongodb make Application not responding

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt5mongodbmongocxxthreadqt creator
7 Posts 3 Posters 952 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Vivek_AV Offline
    Vivek_AV Offline
    Vivek_A
    wrote on last edited by Vivek_A
    #1

    Data reading fast in Qt creator , i used to sent this data to mongodb .
    When i written db["Tag1"].update_one method it makes application not responding.
    so then i tried builk write
    it also makes haang to application…
    how to solve this

    code part"

    
     mongocxx::client& conn1 = get_client();
     mongocxx::database db;
     db = conn1["ASSET_TRACKING"];
    
         if (k != -1)
                    {
                     // qDebug() << "value found at "<<k ;
    
                     qWarning("Got db conn");
    
                    switch(k)
                    {
                      case 0 :
                      {
                         std::vector<bsoncxx::document::value> documents;
                         documents.push_back(
                         bsoncxx::builder::stream::document{} <<"tag_ID"<< e.toStdString() <<"POSX"<<posx<<"POSY"<<posy<<"POSZ"<<posz<< finalize);
                         db["Tagdemo"].insert_many(documents);
    

    // if(posx<30 &&posy<30)
    // {
    // db["Tag1"].update_one(bsoncxx::builder::stream::document{} <<"bool"<< 1 << finalize,
    // bsoncxx::builder::stream::document{} << "$set" << open_document <<
    // "tag_ID"<< e.toStdString() <<"POSX"<<posx<<"POSY"<<posy<<"POSZ"<<posz << close_document << finalize);
    //
    // }
    }

    vk

    jsulmJ 1 Reply Last reply
    0
    • Vivek_AV Vivek_A

      Data reading fast in Qt creator , i used to sent this data to mongodb .
      When i written db["Tag1"].update_one method it makes application not responding.
      so then i tried builk write
      it also makes haang to application…
      how to solve this

      code part"

      
       mongocxx::client& conn1 = get_client();
       mongocxx::database db;
       db = conn1["ASSET_TRACKING"];
      
           if (k != -1)
                      {
                       // qDebug() << "value found at "<<k ;
      
                       qWarning("Got db conn");
      
                      switch(k)
                      {
                        case 0 :
                        {
                           std::vector<bsoncxx::document::value> documents;
                           documents.push_back(
                           bsoncxx::builder::stream::document{} <<"tag_ID"<< e.toStdString() <<"POSX"<<posx<<"POSY"<<posy<<"POSZ"<<posz<< finalize);
                           db["Tagdemo"].insert_many(documents);
      

      // if(posx<30 &&posy<30)
      // {
      // db["Tag1"].update_one(bsoncxx::builder::stream::document{} <<"bool"<< 1 << finalize,
      // bsoncxx::builder::stream::document{} << "$set" << open_document <<
      // "tag_ID"<< e.toStdString() <<"POSX"<<posx<<"POSY"<<posy<<"POSZ"<<posz << close_document << finalize);
      //
      // }
      }

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Vivek_A said in Fast writing to mongodb make Application not responding:

      code part

      What code is that?
      What is db?
      Do you do it in a loop?
      Please explain better!

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      Vivek_AV 1 Reply Last reply
      0
      • jsulmJ jsulm

        @Vivek_A said in Fast writing to mongodb make Application not responding:

        code part

        What code is that?
        What is db?
        Do you do it in a loop?
        Please explain better!

        Vivek_AV Offline
        Vivek_AV Offline
        Vivek_A
        wrote on last edited by Vivek_A
        #3

        @jsulm Ok, iam using qtcreator 5, Database mongodb .
        above code is placed inside a loop ,loop works when there is data available in socket .Data reads fast from socket, when i put mongodb insertion code here it makes application not responding ,,
        can we call mongodb insertion faster??
        is that code logic problem or need to do it in thread??

        vk

        jsulmJ 1 Reply Last reply
        0
        • Vivek_AV Vivek_A

          @jsulm Ok, iam using qtcreator 5, Database mongodb .
          above code is placed inside a loop ,loop works when there is data available in socket .Data reads fast from socket, when i put mongodb insertion code here it makes application not responding ,,
          can we call mongodb insertion faster??
          is that code logic problem or need to do it in thread??

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Vivek_A I also asked what "db" is in your code. Can you please answer?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          Vivek_AV 1 Reply Last reply
          0
          • jsulmJ jsulm

            @Vivek_A I also asked what "db" is in your code. Can you please answer?

            Vivek_AV Offline
            Vivek_AV Offline
            Vivek_A
            wrote on last edited by
            #5

            @jsulm db i updated above

            vk

            jsulmJ JonBJ 2 Replies Last reply
            0
            • Vivek_AV Vivek_A

              @jsulm db i updated above

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Vivek_A You are asking about mongocxx::database which has nothing to do with Qt!
              Are you doing these inserts in main (GUI) thread? If so move this code into a second thread to not to block your main thread.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • Vivek_AV Vivek_A

                @jsulm db i updated above

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #7

                @Vivek_A
                I note that all your questions are about mongodb, its performance, and so on. Have you tried joining some mongodb forum where these might be better answered?

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved