I’ve changed the app to populate v with the query result and noted the free ram before and after each resize. I’m hoping that addresses some of the concerns re compiler optimisations even if it doesn’t supply any real answers? Results were similar to before.
#include <vcl.h> #include <windows.h> #pragma hdrstop #pragma argsused #include <tchar.h> #include <stdio.h> #include <conio.h> #include <iostream> #include <vector> #include "sqlite.h" std::vector<int64_t> v; const int Size[]={112000000,1000000000}; // 112 million, 1 billion uint64_t FreeMBs() { MEMORYSTATUSEX status; status.dwLength = sizeof(status); GlobalMemoryStatusEx(&status); return status.ullAvailPhys / (1024 * 1024); } int _tmain(int argc, _TCHAR* argv[]) { sqlite3 *DB; sqlite3_open("c:/SQLiteData/MyTemp.db",&DB); sqlite3_stmt *stmt; sqlite3_prepare_v2(DB,"select RowID from Big order by RowID",-1,&stmt,NULL); std::cout << FreeMBs() << " MB" << std::endl; for (int i=0; i<2; i++) { v.resize(Size[i]); v.shrink_to_fit(); int64_t Memi=FreeMBs(); clock_t Start=clock(); for (int i=0; i<Size[0] && sqlite3_step(stmt)==SQLITE_ROW; i++) v[i]=sqlite3_column_int64(stmt,0); std::cout << 1.0*(clock()-Start)/CLOCKS_PER_SEC << " secs - Mem" << i << " = " << Memi << " MB" << std::endl; sqlite3_reset(stmt); } sqlite3_finalize(stmt); sqlite3_close(DB); getch(); return 0; } OUTPUT (5 runs) 12891 MB 21.234 secs - Mem0 = 12042 MB 26.828 secs - Mem1 = 5290 MB 12951 MB 22.344 secs - Mem0 = 12092 MB 27.063 secs - Mem1 = 5332 MB 12658 MB 22.938 secs - Mem0 = 11803 MB 27.047 secs - Mem1 = 5071 MB 12820 MB 22.734 secs - Mem0 = 11970 MB 26.688 secs - Mem1 = 5211 MB 12803 MB 22.469 secs - Mem0 = 11954 MB 26.609 secs - Mem1 = 5209 MB _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users