Results 1 to 5 of 5

Thread: SQL slow query - table update

  1. #1
    Join Date
    Sep 2009
    Posts
    20
    Thanked 2 Times in 2 Posts

    Default SQL slow query - table update

    Hello,

    I use QTableView with QSqlQueryModel to display sql query result,
    It works nice but sometimes I have slow query (30-60s, there are few milion rows in database) and I want to update table during query to show partial result. Is is possible using simple code?

    Thx

  2. #2
    Join Date
    Jan 2008
    Location
    Davao City, Philippines
    Posts
    77
    Thanks
    16
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: SQL slow query - table update

    Quote Originally Posted by lasher View Post
    It works nice but sometimes I have slow query (30-60s, there are few milion rows in database) and I want to update table during query to show partial result.
    What about MySql's 'slow query log'?

    http://dev.mysql.com/doc/refman/5.1/...query-log.html

  3. #3
    Join Date
    Sep 2009
    Posts
    20
    Thanked 2 Times in 2 Posts

    Default Re: SQL slow query - table update

    Hi,

    Thx for reply, but I don't use MySQL, I use PostgrSQL, this query log consists only slow query statements.

    I want to update QTableView with QSqlQueryModel, when I execute query (setQuery())
    I have to wait till end of this query to get result (sometimes more than 30s), so I want to refresh QTableView (let say every second) and get partial result updated every second till final end of my query.

    Greetings!

  4. #4
    Join Date
    Oct 2009
    Posts
    5

    Default Re: SQL slow query - table update

    Quote Originally Posted by lasher View Post
    Hello,

    I use QTableView with QSqlQueryModel to display sql query result,
    It works nice but sometimes I have slow query (30-60s, there are few milion rows in database) and I want to update table during query to show partial result. Is is possible using simple code?

    Thx
    Did you found the solution? I'm interested in that too

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,677
    Thanks
    13
    Thanked 1,596 Times in 1,524 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: SQL slow query - table update

    If the long run time is the database server determining what rows to return then there's nothing you can do to display partial results during this time. There are no rows to return and display until after this stage. Make sure you have a good query that makes best use of indexes in the data and only returns columns you need. Full table scans are bad with multi-millions of rows in a table.

    If the long run time is predominantly returning the rows after the database engine has selected them then you might have some options. QSqlTableModel already does lazy retrieval of small batches (~256) from large row sets as a view (QTableView) scrolls down. Scrolling through large data sets can be tedious though. You can bundle the entire delay into a single loop after the model select() using canFetchMore() and fetchMore().

    If the process is slowed by a network connect to the database server you might find some useful ideas here for asynchronous retrieval (thanks Wysota):
    http://blog.wysota.eu.org/index.php/...remote-models/

Similar Threads

  1. Best way to abort long SQL query?
    By wdezell in forum Newbie
    Replies: 1
    Last Post: 11th September 2009, 23:05
  2. SQL query - navigation buttons
    By apffal in forum Qt Programming
    Replies: 1
    Last Post: 5th August 2009, 09:38
  3. MS SQL Query
    By baray98 in forum General Programming
    Replies: 0
    Last Post: 14th July 2009, 05:25
  4. long sql result slow QTableView
    By skuda in forum Qt Programming
    Replies: 1
    Last Post: 20th January 2009, 09:41
  5. QTableWidget Sql Query 25.000 records
    By aekilic in forum Qt Programming
    Replies: 2
    Last Post: 12th August 2008, 15:54

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.