Reputation: 1254
I'm using a QSqlQuery
object to do a linear walk of a 10million row SQL table with a very complex 6 column primary key in sorted order. Because of the key(which I CAN NOT change), breaking upmy query SELECT * FROM table1
with <
or >
with LIMIT
causes a huge number of issues with the algorithm I'm using.
My problem arising is as follows, for whatever reason QSqlQuery
seems to be caching the entire result set in memory until it hits a bad alloc and kills the application. So I may read some couple hundred rows, seek()
over a couple hundred thousand, and by this point QSqlQuery
is using 300mb of memory and my application dies. I read the docs and it seems the only thing that can be done is to use setForwardOnly()
, however I often have a need for previous()
(which is why breaking up the query with LIMIT is a PITA)
Is there no way to cap the cache for QSqlQuery
?
Upvotes: 0
Views: 607
Reputation: 179809
Why don't you store previous
yourself? There's a QContiguousCache
which seems ideal for this.
Upvotes: 1