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