Results 1 to 5 of 5

Thread: performance of Using QSqlQuery to access table containing blob coloumn

  1. #1
    Join Date
    Jan 2014
    Posts
    20
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default performance of Using QSqlQuery to access table containing blob coloumn

    Hi,
    As subject, i use QSqlQuery to access tableA which contains column storing blob data as follows,
    Qt Code:
    1. QSqlQuery query("SELECT * FROM tableA");
    2. while (query.next()) {
    3. i++;
    4. }
    To copy to clipboard, switch view to plain text mode 
    The speed of query is too slow which need about 5s to execute whole "while" loop, is there any idea to improved it? How to deal with blob?
    Thanks!

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: performance of Using QSqlQuery to access table containing blob coloumn

    The Database must provide you with the entire contents of the table, although you are using for anything. Why are you surprised?
    What is Yours real problem - what You want to do ?

  3. #3
    Join Date
    Jan 2014
    Posts
    20
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default QSqlQuery speed problem

    Hello,

    I have a Oracle database with a large dataset, around 200000 rows.
    These rows are selected from the database with a QSqlQuery like this:
    Qt Code:
    1. QSqlQuery query("SELECT * FROM tableA");
    2. while (query.next()) {
    3. i++;
    4. }
    To copy to clipboard, switch view to plain text mode 
    If one of the fields of tableA is blob type (the size of each blob is less than 5M), to get all the rows in a while loop need about 5 seconds. But if i do a query with the command which select all fields except the fileld of blob type, the speed becomes fast.
    Why? What can i do to make the former as fast as the latter?
    Thanks very much!

  4. #4
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: performance of Using QSqlQuery to access table containing blob coloumn

    Why? What can i do to make the former as fast as the latter?
    Because the BLOB is probably big and it requires a huge amount of processing power to query all these rows from database into memory. If you don't select it in your query, then database driver will not load BLOBs into memory, which allows it to complete faster.
    If you need to do some kind of processing on these rows then display a progress dialog or something. What is your task anyway ? I doubt you will increment an integer in your final code, if you give us more details then maybe we can help to optimize your code.

  5. #5
    Join Date
    Jan 2014
    Posts
    20
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: performance of Using QSqlQuery to access table containing blob coloumn

    Quote Originally Posted by stampede View Post
    Because the BLOB is probably big and it requires a huge amount of processing power to query all these rows from database into memory. If you don't select it in your query, then database driver will not load BLOBs into memory, which allows it to complete faster.
    If you need to do some kind of processing on these rows then display a progress dialog or something. What is your task anyway ? I doubt you will increment an integer in your final code, if you give us more details then maybe we can help to optimize your code.
    Thank you first!
    I just want to select all the rows as fast as possible ,how to make it with QSqlTableModel?

Similar Threads

  1. QSqlQuery Insert BLOB, But Not all the BLOB Is Inserted?
    By zerokewl in forum Qt Programming
    Replies: 0
    Last Post: 10th September 2013, 08:06
  2. QsqlQuery to access all the value
    By robotics in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2011, 11:19
  3. QSqlQuery::prepare() - placeholder as table name
    By dawwin in forum Qt Programming
    Replies: 2
    Last Post: 7th March 2011, 22:40
  4. How to delete results of QSqlQuery from table ?
    By homerun4711 in forum Newbie
    Replies: 2
    Last Post: 14th February 2011, 23:50
  5. QSqlQuery and bad performance!
    By mismael85 in forum Qt Programming
    Replies: 9
    Last Post: 25th September 2010, 00:39

Tags for this Thread

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.