-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 05/05/12 10:18, Patrik Nilsson wrote: > Is it possible to get the total number of virtual machine instructions > an operation is requiring?
You know how many there are in the program via explain, but you will not know how many will be executed. For example it is only a few instructions to loop over every row in a table, but that loop will be executed repeatedly for every row. > I want to use "sqlite3_progress_handler" during "vacuum" to inform the > user of the relative progress, i.e. sending vacuum to a 3 gigabyte > database takes a while. Possible? vacuum is a single virtual instruction. If you wanted to show progress of a vacuum you could monitor the size of the database file or journal as a proportion of the size of the original file although this may not be that useful depending on how the vacuum is being done. (The final file size is unlikely to be the same as the original, but any progress calculations will be good enough.) > Is it possible to get the total number of virtual machine instructions > a "begin... commit"-statement will need? I.e. progress of saving data > to the database. You already know the answer since you are providing the insert statements and executing them one at a time. Divide how many have already been submitted versus how many there were in total. If you do lengthy operations at the end such as indexing then the usual approach to make the data insertion add up to 90% progress and the rest be 10%. Again this won't be accurate, but it will be good enough. Something else you can consider is changing how your program works so that the user interface isn't slaved to database operations. You can let the UI queue up work to be done, and then have a background worker thread actually do the work in the queue. Save the queue in a separate database so that work can be resumed even if the application crashes or is terminated. (BTW this is how many mobile apps operate because db operations can take quite a while and they also have to be synced to a server over uncertain network connections.) Roger -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iEYEARECAAYFAk+lcIEACgkQmOOfHg372QRiAwCfXZ4KuBNOppllW+HY2os8+wzw IdsAoI3UKPIKFhQVGJZC1tJdbPD6qyf6 =uaYR -----END PGP SIGNATURE----- _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users