qt - QSqlQuery buffer size -
i have large table in postgresdb (55gb). want scan in c++ qt, summarize result, , send db. far understand, default qsqlquery transfers data main memory. possible state explicit buffer size object? possible tell qt/postgres answer incrementally, i.e., not after data comuted , sent c++ program?
the code using following:
qsqldatabase db = qsqldatabase::adddatabase("qpsql"); db.sethostname("server"); db.setdatabasename("db"); db.setusername("user"); db.setpassword("pass"); bool ok = db.open(); qsqlquery query; query.setforwardonly(true); query.prepare("select attributes verylargetable"); while (query.next()) { int = query.value(0).toint(); // , work data }
i saw answer on net recently, spent hours looking answer again without success.
i split select (of course in transaction). first determine imaxlines
size of select like:
select count(*) verylargetable
if want read 1000 lines ad once, can somethin this
select attribute verylargetable limit 1000 offset x
where x
can iterating 0, 1000, 2000,..., imaxlines-1000
regards, lars
Comments
Post a Comment