Skip to content

Instantly share code, notes, and snippets.

@suya55
Last active November 22, 2019 08:46
Show Gist options
  • Save suya55/41b47b2913cb0f64a75e2ea6df76d19b to your computer and use it in GitHub Desktop.
Save suya55/41b47b2913cb0f64a75e2ea6df76d19b to your computer and use it in GitHub Desktop.
Rails select query 추출.
$ yum install cargo; cargo install sd
egrep '(SELECT|UPDATE)' production.log | awk -F']' '{ print $3 }'  | awk -F"ms)" '{ print $2 }' | sd "'[a-z0-9/ \.\-:]+'" '?'  | sd '= [0-9]+' '= ?'  | sd '[0-9]+ ?(, ?[0-9]+)+' '?' | sd '(, ?\?+)' '' | sd "'%.+%'" '?'  | sd 'LIMIT [0-9]+' 'LIMIT ?' | sd 'OFFSET [0-9]+' 'OFFSET ?'  | sort | uniq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment