On 2018/01/04 7:56 AM, Junyoung Park wrote:
Hi,

I am currently testing to check database corrupted / malformed.
Database size :1G

.....
The main point of the question is that if the "quick_check" is slow
according to the size of the database,
in order to confirm the checking of malformed of the DB I would like
to ask if I can replace it with the above select statement instead of
"integrity_check" or "quick_check".

In addition to David's clear description, consider also that SELECT MAX(rowid) FROM... or similar things like SELECT COUNT(*) FROM... that the DB engine shortcuts to an optimization reading typically only a page or two from the best Index (with rowid the Index is implicit) and in no way checks any integrity.  (One could possibly deduce, should the operation not error out AND return quick, that the Index is present, at the least).

On the other hand, during an integrity check the engine needs to check a lot more. It needs to verify that the rows referenced by the Index, all Indexes in fact, are indeed present and pointing correctly. It further has to ensure the Index(es) itself, even if correctly pointing, do not violate any Index specific constraints (Uniqueness etc.), and a few more things - all of which simply illustrates that testing DB integrity, even the quick kind, is a laborious exercise and quick-scanning the Index in any way would defeat the purpose.

Why the frequent need to test for corruption? Do you often get corruption? If so, then perhaps solving that problem is a more worthy exercise?

Cheers,
Ryan

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to