1. 3
  1.  

  2. 2

    My favorite psql “optimization” is actually a readline hack. Add this to your .inputrc:

    "\e[A": history-search-backward
    "\e[B": history-search-forward
    set show-all-if-ambiguous on
    set completion-ignore-case on
    

    Now you can do easy prefix history search. Type “select”, and hit up arrow, and you’ll see the last select statement you ran. Keep hitting up arrow for additional matches, back into history. I frequently type “select cli<uparrow>” to get my commonly-used “select client_addr, count(*) from pg_stat_activity group by client_addr;”.

    It affects any readline-enabled app you use, including (in most cases) your shell. It’s now one of the first rc files I set up on a new system.

    1. 3

      I’ve been able to pretty effectively use CTRL-r for that purpose without having to edit the inputrc.

      1. 1

        Glad that works for you. The readline hack has been incredibly productive for me in my day-to-day.