Re: Analyzing last run query in psql - Mailing list pgsql-general

From Luca Ferrari
Subject Re: Analyzing last run query in psql
Date
Msg-id CAKoxK+65Cxdy56tUg8c_+8hJgqmry0ub5HpBVpPtBMvL65eiJw@mail.gmail.com
Whole thread Raw
In response to Analyzing last run query in psql  (Joe Van Dyk <joe@tanga.com>)
List pgsql-general
On Wed, Jul 3, 2013 at 7:05 AM, Joe Van Dyk <joe@tanga.com> wrote:
> I frequently need to analyze the last query in psql:
>     select * from table where id = 1;
>     explain analyze select * from table where id = 1;
>
> It would be nice to be able to do this:
>     explain analyze $LAST
>
> (or can I do something like that already?)
>
> I'm not using psql interactively, I pipe files into psql (if it matters).


I don't know of any feature like that, but maybe you can do the
following in your script/files:

\set lastquery 'your-query-here'

so that you can do something like

explain :lastquery;

But if you are able to manipulate your scripts you can just insert the
explain by hand on queries you are interested in, or use autoexplain
for all the queries.

Luca


pgsql-general by date:

Previous
From: Andreas Kretschmer
Date:
Subject: Re: Analyzing last run query in psql
Next
From: Oleg Bartunov
Date:
Subject: Re: Analyzing last run query in psql