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. Avoiding sp_cursorfetch with QSqlxxxx
QtWS25 Last Chance

Avoiding sp_cursorfetch with QSqlxxxx

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.5k Views
  • 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.
  • H Offline
    H Offline
    hsfougaris
    wrote on last edited by
    #1

    I have an app that uses a QSqlDatabase connecting to an MS SQL Server through ODBC.
    I noticed, that all classes available for data retrieval (like QSqlQuery, QSqlQueryModel, QSqlTableModel) use sp_cursorfetch.

    Isn't there a way to just retrieve the whole table at once, or at least specify the batch size?
    I'm trying to do some processing on each row of the data, and I end up making too many calls to the database
    ie.

    • if I use QSqlQuery.next(), I get a call to the database every time I call next()
    • if I use QSqlQueryModel I have to use something like: while canFetchMore() fetchMore in order to get the data (which is again numerous calls to the database)

    If you can't say what you mean, you'll never be able to mean what you say.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      stukdev
      wrote on last edited by
      #2

      Are you sure QSqlQuery.next() get a call to the database? I think next() retrieve the next row from a prevent exec()

      1 Reply Last reply
      0
      • H Offline
        H Offline
        hsfougaris
        wrote on last edited by
        #3

        Yes, I am very sure....
        I get a call for every next() call.
        The output from SQL Server profiler is like this:

        1) exec sp_cursoropen ....

        2) exec sp_cursorfetch 180150003,1,0,1

        3) exec sp_cursor 180150003,40,1

        4) Repeat 2) and 3) for each record returned by the query

        If you can't say what you mean, you'll never be able to mean what you say.

        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