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. [Solved] how to speed up. QSQLite INSERT query?
Forum Updated to NodeBB v4.3 + New Features

[Solved] how to speed up. QSQLite INSERT query?

Scheduled Pinned Locked Moved General and Desktop
15 Posts 4 Posters 11.0k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    mabrand
    wrote on last edited by
    #6

    You should probably check this "faq":http://www.sqlite.org/faq.html#q19.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      shint
      wrote on last edited by
      #7

      thank you. mabrand.
      i will see.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        js_dev
        wrote on last edited by
        #8

        I do it like described "here":http://doc.qt.nokia.com/4.7/qsqlquery.html#prepare.

        This works fine and is fast enough for my software.

        Don't forget the @db.transaction()@ and @db.commit()@ before and after your query.

        Don't be afraid of perfection, you will never reach it.
        (Salvator Dali)

        1 Reply Last reply
        0
        • S Offline
          S Offline
          shint
          wrote on last edited by
          #9

          O_T js_dev.
          thank you for being so caring.

          i just do it!

          1 Reply Last reply
          0
          • S Offline
            S Offline
            shint
            wrote on last edited by
            #10

            thank you. very much. js_dev.
            and. with mabrand.

            i success.
            i applyed transaction() and commit().
            and very fast write!.

            have a nice day~~ O_O~~;;;;

            1 Reply Last reply
            0
            • J Offline
              J Offline
              js_dev
              wrote on last edited by
              #11

              Great :-)

              Don't be afraid of perfection, you will never reach it.
              (Salvator Dali)

              1 Reply Last reply
              0
              • S Offline
                S Offline
                shint
                wrote on last edited by
                #12

                O_O~~

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goetz
                  wrote on last edited by
                  #13

                  [quote author="shint" date="1296545085"]
                  //use prepare. addBindValue.
                  @
                  QString tmp, str;
                  for(int row = 0; row < nRowCount; row++)
                  {
                  query.prepare(qsInsertTable);
                  int nValueCount = 0;
                  for(int col = 0; col < nColumnCount; col++)
                  {
                  @[/quote]

                  You should prepare your statement once (outside the for row statement) and use it multiple times. You actually do it the other way round: You create a single new prepared statement for each row you insert. This does not save you time, but cost you.

                  http://www.catb.org/~esr/faqs/smart-questions.html

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    js_dev
                    wrote on last edited by
                    #14

                    [quote author="Volker" date="1296556882"]
                    [quote author="shint" date="1296545085"]
                    //use prepare. addBindValue.
                    @
                    QString tmp, str;
                    for(int row = 0; row < nRowCount; row++)
                    {
                    query.prepare(qsInsertTable);
                    int nValueCount = 0;
                    for(int col = 0; col < nColumnCount; col++)
                    {
                    @[/quote]

                    You should prepare your statement once (outside the for row statement) and use it multiple times. You actually do it the other way round: You create a single new prepared statement for each row you insert. This does not save you time, but cost you.[/quote]

                    Good point! I haven't seen this.

                    Don't be afraid of perfection, you will never reach it.
                    (Salvator Dali)

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      shint
                      wrote on last edited by
                      #15

                      O_O'''' oh! i understand.
                      Volker. good man. thank you.

                      to prepare() for a worry I will try to use.

                      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