Created
April 9, 2012 04:25
-
-
Save morimori/2341425 to your computer and use it in GitHub Desktop.
optimize sqlite database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find -type f -print0 | xargs -0 file | grep SQLite | awk -F : '{print $1}' | xargs -n1 -d "\n" sqlite_optimizer.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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