Re: contrib/pg_stat_statements - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: contrib/pg_stat_statements
Date
Msg-id 20081016012336.GK6012@alvh.no-ip.org
Whole thread Raw
In response to Re: contrib/pg_stat_statements  (ITAGAKI Takahiro <itagaki.takahiro@oss.ntt.co.jp>)
Responses Re: contrib/pg_stat_statements
List pgsql-hackers
ITAGAKI Takahiro wrote:

> We need to avoid using normal UPDATEs to increment counters
> because it requires row-level exclusive locks and kills concurrency.
> My idea was modifying heap tuples directly in pages:
> 
>     buffer = ReadBuffer(stats_rel, blknum);
>     LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
>     htup = PageGetItem(BufferGetPage(buffer), itemid);
>     statobj = ((char *) htup + htup->t_hoff);
>     statobj->calls++;
>     LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
> 
> It seemed to work in my test, but of course it is too dangerous.
> (If we had supported ISAM-like storage engine, we might use it here.)

heap_inplace_update?


-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


pgsql-hackers by date:

Previous
From: ITAGAKI Takahiro
Date:
Subject: Re: contrib/pg_stat_statements
Next
From: ITAGAKI Takahiro
Date:
Subject: Re: contrib/pg_stat_statements