Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

It is somewhat annoying to type EXPLAIN (ANALYZE, BUFFERS, VERBOSE) in psql tool every time you tune queries.

So, is there a way to define an aliases (autocompletable ones would be very nice) in psql similar to the way it is in bash?

E.g. FULLEXPLAIN SELECT * FROM pg_stat; results into EXPLAIN (ANALYZE, BUFFERS, VERBOSE) SELECT * FROM pg_stat;

share|improve this question

1 Answer 1

up vote 3 down vote accepted
\set fullexplain EXPLAIN (ANALYZE, BUFFERS, VERBOSE)

:fullexplain SELECT * FROM pg_stat;.

Probably not the most elegant thing I admit.

Also you could put this in .psqlrc.

share|improve this answer
    
Worked like a charm, thanks! –  НЛО May 23 at 7:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.