A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Escape quotes correctly for looping over nested ssh commands

$ for server in $(cat servers); do echo $server $(ssh -A user@bastion "ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $server \"/bin/bash -c \\\"which mysqldump\\\"\" "); done

Output:
foo-2 /usr/bin/mysqldump
bar-4 /usr/bin/mysqldump
baz-12 /usr/bin/mysqldump
qux-3 /usr/bin/mysqldump
quxx-4 /usr/bin/mysqldump

MySQL explain plan cheat sheet

Explanation of explain output:

  • select_type: SIMPLE/SUBQUERY/UNION/DERIVED
  • partitions: NULL ??
  • type: (from worst to the best): ALL, index, range, ref, eq_ref, const, system
  • possible_keys: food,bar,baz,id (good)
  • key: foo(good)
  • key_len: 334 ??
  • ref: const,const,const ??
  • rows: 1 (lower is better. must be less than total rows)
  • filtered: 100.00 (lower is better, but only used if there's a join)
  • Extra: NULL
Bad extra values:
  • using where
  • using temporary
  • using filesort
Good extra values:
  • using index