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

InsertRecord performance in QSqlTableModel.

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 2.7k 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.
  • Z Offline
    Z Offline
    zither
    wrote on last edited by
    #1

    Dear all,

    @if (file.open(QIODevice::Readonly))
    {
    while (!file.atEnd()){
    QString str = file.readLine();
    QStringList strList = str.split("\t"); //parsing tab separated file
    QSqlTableModel.insertRecord(0,makeRecord(strList)); //makeRecord returns QSqlRecord
    }
    }@

    That cause serious performance problem. It takes 1 min to parse about 20K lines of file. What's wrong with that code?

    Thanks

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dangelog
      wrote on last edited by
      #2

      No idea. Profile your program, switch to the manual submit strategy and call submitAll, consider using QSqlQuery inside ONE transaction, etc.

      Software Engineer
      KDAB (UK) Ltd., a KDAB Group company

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        zither
        wrote on last edited by
        #3

        Thanks for advice.

        I already set manual submit. It just to add data to table & manual submitAll later.

        I'll try with QSqlQuery to source Table..

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          zither
          wrote on last edited by
          #4

          @peppe

          I can't get it, QSqlQuery inside ONE transaction is worsen than insertion of table row...

          How can I do that?

          1 Reply Last reply
          0
          • Z Offline
            Z Offline
            ZapB
            wrote on last edited by
            #5

            Where does the profiler say most of the time is being spent?

            Try using QSqlQuery directly rather than via the table model.

            Nokia Certified Qt Specialist
            Interested in hearing about Qt related work

            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