Skip to content

Instantly share code, notes, and snippets.

@morimori
Created April 9, 2012 04:25
Show Gist options
  • Save morimori/2341425 to your computer and use it in GitHub Desktop.
Save morimori/2341425 to your computer and use it in GitHub Desktop.
optimize sqlite database
find -type f -print0 | xargs -0 file | grep SQLite | awk -F : '{print $1}' | xargs -n1 -d "\n" sqlite_optimizer.sh
#! /bin/sh
if [ "$1" = "" ]; then
echo "Usage: $0 [DB_FILE]"
exit 1
fi
if [ ! -e "$1" ]; then
echo "$1 is not exists."
exit 1
fi
BEFORE=`stat -c %s "$1"`
sqlite3 "$1" vacuum && sqlite3 "$1" reindex
echo "$1: ${BEFORE} -> `stat -c %s "$1"`"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment