Unix Technical Forum

select updates pg_stat_database

This is a discussion on select updates pg_stat_database within the Pgsql General forums, part of the PostgreSQL category; --> I have noticed that all SELECT queries alone in a transaction also update pg_stat_database (I know it's just a ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-09-2008, 11:01 AM
Jeff Davis
 
Posts: n/a
Default select updates pg_stat_database

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()).

Does that mean that SELECTs by themselves require a disk write? If so,
is that a synchronous disk write? Is it due to something else entirely
(like autovacuum or the statistics collector)?

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

Thanks,
Jeff Davis


---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-09-2008, 11:01 AM
Alvaro Herrera
 
Posts: n/a
Default Re: select updates pg_stat_database

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.

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:44 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com