Re: Extracting SQL from logs in a usable format

From: Rory Campbell-Lange <rory(at)campbell-lange(dot)net>
To: Chris Ernst <cernst(at)esoft(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Extracting SQL from logs in a usable format
Date: 2009-12-18 21:48:03
Message-ID: 20091218214803.GB22180@campbell-lange.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 18/12/09, Chris Ernst (cernst(at)esoft(dot)com) wrote:
> I have a project where I need to be able to capture every query from a
> production system into a file such that I can "replay" them on a staging
> system. Does such a thing already exist or should I start writing my
> own log parser?

I'm sure there are a number of log replay systems already in existence.
Perhaps you could use Londiste, and introduce a lag to the replication
process if it is required?
http://skytools.projects.postgresql.org/doc/londiste.ref.html#toc17

A very simple way of doing this is to log all of the SQL statements by
setting the postgresql.conf parameter log_min_duration_statement to 0.
You can then easily parse out the SQL statements from the log file.
I have done this before quite successfully when wishing to replay a long
set of SQL statements to test un upgrade of a Postgresql server.

Rory

--
Rory Campbell-Lange
Director
rory(at)campbell-lange(dot)net

Campbell-Lange Workshop
www.campbell-lange.net
0207 6311 555
3 Tottenham Street London W1T 2AF
Registered in England No. 04551928

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2009-12-18 21:55:08 Re: Extended Query, flush or sync ?
Previous Message Raimon Fernandez 2009-12-18 21:44:10 Extended Query, flush or sync ?