Re: select updates pg_stat_database

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: select updates pg_stat_database
Date: 2006-08-14 21:10:25
Message-ID: 20060814211025.GB5605@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jeff Davis wrote:
> I have noticed that all SELECT queries alone in a transaction also
> update pg_stat_database (I know it's just a view that calls
> pg_stat_get_db_xact_commit()).

The stuff in the stats collector is not stored on disk. Or, rather, it
is, but not in the same way as regular tables; in particular, it's not
fsynced.

> Also, is there a way to retrieve the current transaction id?

Some people like to write a C function calling GetTopTransactionId() to
get it. If you want it for a quick experiment, you can create a temp
table and examine pg_class.xmin for that table.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Enver ALTIN 2006-08-14 21:23:40 Re: wal files on temporary tables
Previous Message Brad Nicholson 2006-08-14 20:59:08 Re: Best approach for a "gap-less" sequence