Advertisement
rockdrilla

find and speedup SQLite 3.x databases

Jul 29th, 2014
585
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.40 KB | None | 0 0
  1. #!/bin/bash
  2. find ~ -size +1k -type f -print0 | \
  3. while read -d '' F; do
  4.   A=$(readlink -f "$F")
  5.   file -b "$A" | egrep -qe '^SQLite 3' || continue
  6.   size_before=$(stat -c %s "$A")
  7.   sqlite3 "$A" "VACUUM; REINDEX;" > /dev/null 2>&1
  8.   size_after=$(stat -c %s "$A")
  9.   echo -n "$F: ${size_before} -> ${size_after}, "
  10.   echo "scale=2; (${size_after}/${size_before})*100" | bc -l
  11. done
  12. sleep 1
  13. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement