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. Slow EC2 MySQL database (xampp) access

Slow EC2 MySQL database (xampp) access

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 213 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.
  • D Offline
    D Offline
    DiogoIDENG
    wrote on 7 Aug 2024, 15:15 last edited by
    #1

    Hello,
    I'm using AWS EC2 as cloud server for MySQL database (xampp) and I'm getting data so slow that my app crash. Is it network configuration, weak instance type?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 7 Aug 2024, 19:12 last edited by
      #2

      Hi,

      How exactly does it crash ?
      What's the database size ?
      What kind of query are you sending ?
      What is your connection speed ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DiogoIDENG
        wrote on 8 Aug 2024, 08:44 last edited by
        #3

        The problem starts after using a lineedit, where for each letter, she gets data from the database.
        If I wait for the getting data process, it works, but it is so slow.
        The database is 976.0 KB.
        An example of query type is:
        query_pesquisa.prepare("SELECT * FROM lista_artigos Where Designacao LIKE :designacao AND ID=:id_art");
        The latency is slow, and I try to use a better instance type, but it is still slow.

        One thing that I saw is, if I only have one query in the function, it is fast, but if I use a query inside another query, it is slow.

        I don't understand.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DiogoIDENG
          wrote on 8 Aug 2024, 09:01 last edited by
          #4

          latency is low(44ms)*

          J 1 Reply Last reply 8 Aug 2024, 10:40
          0
          • D DiogoIDENG
            8 Aug 2024, 09:01

            latency is low(44ms)*

            J Offline
            J Offline
            JonB
            wrote on 8 Aug 2024, 10:40 last edited by JonB 8 Aug 2024, 10:41
            #5

            @DiogoIDENG
            There is nothing wrong with your query per se. A 1MB (is it really that small or did you mean 1GB?) is tiny. A nested query will run slower, but that is done up at the database server side, no WAN/latency etc. I'm surprised you even notice a speed difference, not sure what to make of that.

            On a WAN/where you have latency issuing a query for every letter typed is not a good idea. You could compensate for that by doing further work client-side instead. Think about your query:

            Where Designacao LIKE :designacao AND ID=:id_art
            

            I assume LIKE :designacao is used to pattern match against the characters being typed into the line edit. Let's say user starts by typing A as first character. The query returns all rows where Designacao starts with or has an A. Now the user types B as second character. You will issue a new query asking for those starting with or having AB. But by definition that will we a subset of those with A which you already have fetched to the client. So instead of the requerying the database you could just pick from those you already have without going back to the database. (Either do it yourself or use a QSortFilterProxyModel.) Miles faster. You have to deal with if user deletes the A or other such change which makes the original matching rows invalid, but that's not hard to do.

            Furthermore AND ID=:id_art looks like ID is the primary (or other unique?) key. In that case the query can only return either one or no records. Even less reason to go re-querying the database.

            1 Reply Last reply
            0

            1/5

            7 Aug 2024, 15:15

            • Login

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