Skip to content

Instantly share code, notes, and snippets.

@siteshen
Created May 22, 2015 04:18
Show Gist options
  • Select an option

  • Save siteshen/0a73a53030a84112e870 to your computer and use it in GitHub Desktop.

Select an option

Save siteshen/0a73a53030a84112e870 to your computer and use it in GitHub Desktop.
Example of update value of column with millions of rows.
#!/bin/bash
x=0
while [ $x -lt 5432 ]; do
prev=$(expr $x \* 1000000)
next=$(expr $(expr $x + 1) \* 1000000)
echo $(date +'%Y-%m-%d %H:%M:%S'), $prev, $next
x=$(expr $x + 1)
psql -c "UPDATE followships SET is_deleted = false WHERE is_deleted IS NULL and id >= $prev and id <= $next;"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment