Results 1 to 6 of 6

Thread: QtConcurrent and QSqlQuery

  1. #1
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default QtConcurrent and QSqlQuery

    Hi,

    Has anyone experienced on executing multiple INSERT sql queries into MySQL database using QtConcurrent?

    I have to store big data on every query and I want to know if using multiple threads that will execute an INSERT query with the data will increase the insertion speed.

    Thanks,
    Òscar Llarch i Galán

  2. #2
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QtConcurrent and QSqlQuery

    Hi Oscar,

    The general idea shall be like this, create a sql file with data and try to import using mysqlimport

    Hope it helps,
    Bala

  3. #3
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QtConcurrent and QSqlQuery

    Hi,

    Storing the data into a file and then insert the file data into the database? Are you sure that it will speedup my process?

    Thanks,
    Òscar Llarch i Galán

  4. #4
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QtConcurrent and QSqlQuery

    Hi oscar,

    Hope so.Im not sure about that. may be masters like wysota,Lykurg,others can answer this correctly.
    My thought is, inserting from Qt will take much time than db import app.
    May be the db import tool optimized.


    Check with the mysql tuning http://dev.mysql.com/doc/refman/5.1/...db-tuning.html
    hope it helps,
    Bala.


    Added after 4 minutes:


    Some tips on mysql bulk import [from the mysql website],

    When importing data into InnoDB, make sure that MySQL does not have autocommit mode enabled because that requires a log flush to disk for every insert. To disable autocommit during your import operation, surround it with SET autocommit and COMMIT statements:

    SET autocommit=0;
    ... SQL import statements ...
    COMMIT;
    If you use the mysqldump option --opt, you get dump files that are fast to import into an InnoDB table, even without wrapping them with the SET autocommit and COMMIT statements.

    If you have UNIQUE constraints on secondary keys, you can speed up table imports by temporarily turning off the uniqueness checks during the import session:

    SET unique_checks=0;
    ... SQL import statements ...
    SET unique_checks=1;
    For big tables, this saves a lot of disk I/O because InnoDB can use its insert buffer to write secondary index records in a batch. Be certain that the data contains no duplicate keys.

    If you have FOREIGN KEY constraints in your tables, you can speed up table imports by turning the foreign key checks off for the duration of the import session:

    SET foreign_key_checks=0;
    ... SQL import statements ...
    SET foreign_key_checks=1;
    For big tables, this can save a lot of disk I/O.
    Last edited by BalaQT; 10th April 2013 at 12:40.

  5. #5
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QtConcurrent and QSqlQuery

    Hi,

    Think on that I need to store the data into a file first, so I think this will be slower.

    What I want is to create multiple threads that will store the data concurrently. Maybe the concurrent insertion will give me the same insertion time and will not speedup it.

    Thanks,

    Hi,

    Will try to disable "autocommit", insert all data and then reenable it. It maybe will help as I have multiple insertions at a time.

    Thanks,
    Òscar Llarch i Galán

  6. #6
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QtConcurrent and QSqlQuery

    Will try to disable "autocommit", insert all data and then reenable it. It maybe will help as I have multiple insertions at a time.
    u can use transaction and commit for multiple insertions

    bala

Similar Threads

  1. Replies: 2
    Last Post: 9th April 2013, 09:15
  2. Problem with QtConcurrent::run
    By januszmk in forum Newbie
    Replies: 5
    Last Post: 30th July 2011, 17:57
  3. Replies: 1
    Last Post: 18th July 2011, 12:12
  4. qtconcurrent
    By knishaq in forum Qt Programming
    Replies: 4
    Last Post: 15th December 2009, 08:41
  5. QtConcurrent
    By Brandybuck in forum An Introduction to QThreads
    Replies: 2
    Last Post: 9th May 2008, 14:10

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.