Results 1 to 5 of 5

Thread: Qt MySQL big data insertion

  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 Qt MySQL big data insertion

    Hi,

    I'm developing an application that stores images into a MySQL database. It takes images from a camera, inspects the image and save the "detected" zones of the image as little images into the database. To speedup the process it writes the image as the direct camera buffer(not JPG,BMP...) and the width and height of the images to be able to show them when needed. The camera images are 8000x3500px gray(one byte per pixel) and the "detection" images can be 1000x3500px that is 3.3MB.

    The problem that I'm getting is the speed of the execution of the SQL insertion.
    Now I'm using the multiple row insertion way also with a transaction.
    Inserting 42 "detection" images takes from 350ms to 2800ms on different executions.

    Have you any idea how to improve this?

    Thanks,
    Òscar Llarch i Galán

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt MySQL big data insertion

    You are writing 42 by 3MB plus the original image, about 160MB. I think taking less than 3 seconds to transfer that to the RDBMS is not bad, especially if there is a network involved.

  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: Qt MySQL big data insertion

    Hi,

    The original image is not saved, only the "detected" images. The database is on the same computer on a Windows XP machine so it will use shared memory to transfer the data, right?

    Thanks,
    Òscar Llarch i Galán

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt MySQL big data insertion

    It might use of a number of ways to transfer the data from client to server. If the server is started with the --shared-memory option and the client is using the equivalent of the --protocol=MEMORY option then yes, shared memory should be used. It is entirely possible you are talking via the loopback interface.

    You might also see if performing the set of inserts inside a single database transaction has an impact. You get one commit cycle rather than 42.

    I have never used a MySql server on XP. Cannot vouch for its performance.

  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: Qt MySQL big data insertion

    Hi,

    It might use of a number of ways to transfer the data from client to server. If the server is started with the --shared-memory option and the client is using the equivalent of the --protocol=MEMORY option then yes, shared memory should be used
    I have tryied starting the server with "--shared-memory" and using the "setConnectionOptions("--protocol=MEMORY")" and it still needs too much time.

    You might also see if performing the set of inserts inside a single database transaction has an impact. You get one commit cycle rather than 42.
    I'm using the transaction too. I'm using the multiple row insertion way and the transaction and commit calls.

    Using the debugger I can see that the time is wasted in "qsql_mysql.cpp" method "bool QMYSQLResult::exec()" line "r = mysql_stmt_execute(d->stmt);".

    I also have tryied to convert the image to JPG to reduce the size of the data but it needs much more CPU time that storing the direct data.

    Maybe scaling the image to half size and storing the scaling factor into the database will be a good solution thinking on that the quality of the images are not as good as the original.

    Thanks.
    Òscar Llarch i Galán

Similar Threads

  1. Replies: 2
    Last Post: 3rd November 2012, 18:15
  2. Replies: 4
    Last Post: 19th December 2010, 06:15
  3. Qt to Sqlite data insertion doubt.
    By rex in forum Qt Programming
    Replies: 15
    Last Post: 16th December 2010, 12:31
  4. Escape string for insertion into Mysql db ??
    By BillGates in forum Qt Programming
    Replies: 7
    Last Post: 17th October 2010, 11:11
  5. Replies: 0
    Last Post: 4th December 2008, 05:48

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.