Re: EXPLAIN ANALYZE in batch file

From: Willy-Bas Loos <willybas(at)gmail(dot)com>
To: michel wildcat <m(dot)wildcat82(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: EXPLAIN ANALYZE in batch file
Date: 2012-05-22 06:58:03
Message-ID: CAHnozTi7nL2UBaCU9GuYiCzQrmnAejnUo+Trx6ApFzNXJwDqBg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-novice

just make a text file with the sql commands in it.
end each command with a ;
the make a scheduled job that executes the program psql, taking the
commands from the file.

so, i make text file calles test.sql. the contents are:
vacuum analyze;
create table test as select 'hello world'::text;
--the end

then make a scheduled job that executes this command:
psql -f test.sql -U itsme postgres
(psql is the command line client for postgresql, manual here:
http://www.postgresql.org/docs/9.1/static/app-psql.html)

It would ask for a password, so you need to create a way to allow the
script to run without you typing the password.
i use peer authentication, but that is not supported in windows.
you could use the password file for that:
On Microsoft Windows the file is named %APPDATA%\postgresql\pgpass.conf(where
%APPDATA% refers to the Application Data subdirectory in the user's
profile).
It should look like this:

hostname:port:database:username:password

so for example:
localhost:5432:postgres:itsme:secret

HTH

WBL

On Sat, May 19, 2012 at 11:02 AM, michel wildcat <m(dot)wildcat82(at)gmail(dot)com>wrote:

> hello,
> I am working with PostgreSQL 9 in windows (pgAdmin3) and I'm trying to
> execute EXPLAIN ANALYZE command on some queries that are
> really time consumming. I would like to do it at once and send the
> results to a single file.
> can anybody help me to solve this please?
> thanks
>
> --
> Sent via pgsql-novice mailing list (pgsql-novice(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-novice
>

--
"Quality comes from focus and clarity of purpose" -- Mark Shuttleworth

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Willy-Bas Loos 2012-05-22 07:10:16 Re: PG_DUMP producing incorrect SQL
Previous Message michel wildcat 2012-05-21 19:42:08 Fwd: sequential explain analyze command execution