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
Forum Updated to NodeBB v4.3 + New Features

Fast writing to mongodb make Application not responding

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt5mongodbmongocxxthreadqt creator
7 Posts 3 Posters 996 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.
  • V Offline
    V Offline
    Vivek_A
    wrote on 17 Jan 2022, 08:52 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

    J 1 Reply Last reply 17 Jan 2022, 08:53
    0
    • V Vivek_A
      17 Jan 2022, 08:52

      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);
      //
      // }
      }

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 17 Jan 2022, 08:53 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

      V 1 Reply Last reply 17 Jan 2022, 09:25
      0
      • J jsulm
        17 Jan 2022, 08:53

        @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!

        V Offline
        V Offline
        Vivek_A
        wrote on 17 Jan 2022, 09:25 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

        J 1 Reply Last reply 17 Jan 2022, 09:27
        0
        • V Vivek_A
          17 Jan 2022, 09:25

          @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??

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 17 Jan 2022, 09:27 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

          V 1 Reply Last reply 17 Jan 2022, 09:37
          0
          • J jsulm
            17 Jan 2022, 09:27

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

            V Offline
            V Offline
            Vivek_A
            wrote on 17 Jan 2022, 09:37 last edited by
            #5

            @jsulm db i updated above

            vk

            J J 2 Replies Last reply 17 Jan 2022, 09:39
            0
            • V Vivek_A
              17 Jan 2022, 09:37

              @jsulm db i updated above

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 17 Jan 2022, 09:39 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
              • V Vivek_A
                17 Jan 2022, 09:37

                @jsulm db i updated above

                J Offline
                J Offline
                JonB
                wrote on 17 Jan 2022, 09:52 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

                4/7

                17 Jan 2022, 09:27

                • Login

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