A 4.94 GB database copy in 70 seconds

The core service hit a snag.

  • When a schema change is requested, it copies the existing DB to make the appends. It happens under the 90 second mark set in code, but yet sounds slow. 4.94 GB happened in 70 seconds. Pretty show IMO.

  • Then this DB is verified. This is what the bottleneck is. It is being given a window of 15 minutes which is very generous in my head but yet fails.

  • Verification is

  1. Open the snapshot read-only.
  2. Run SQLite’s full PRAGMA integrity_check.
  3. Read the snapshot’s journal sequence.
  4. Read the entire file to calculate a SHA-256 checksum.
  5. Record its size and flush the file and directory to disk.

Database ops roughly 3,000 I/O operations/sec. No RAM or storage issue.

Possible solution : mark timings for integrity check, checksum calculation and final disk flush. This way it can be identified which part is getting stuck.