Re: unlogged tables vs. GIST

Heikki Linnakangas <hlinnakangas@vmware.com>

From: Heikki Linnakangas <hlinnakangas@vmware.com>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Jeevan Chalke <jeevan.chalke@enterprisedb.com>, Tom Lane <tgl@sss.pgh.pa.us>, pgsql-hackers@postgresql.org
Date: 2013-01-15T18:44:37Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. The GiST scan algorithm uses LSNs to detect concurrent pages splits, but

On 15.01.2013 20:33, Robert Haas wrote:
> On Tue, Jan 15, 2013 at 1:10 PM, Heikki Linnakangas
>> Could we stash the counter e.g. in the root page of the index?
>
> That would require maintaining a counter per table rather than a
> single global counter, which would be bad because then we'd need to
> store one counter in shared memory for every table, rather than just
> one, period, which runs up against the fixed sizing of shared memory.

I was thinking of just adding a new field to the root page header, and 
use that field as the counter. Something like:

XLogRecPtr
GetXLogRecPtrForTemp(void)
{
     rootbuf = ReadBuffer(rel, GIST_ROOT_BLKNO);
     opaq = GistPageGetOpaque(BufferGetPage(rootbuf));

     LockBuffer(rootbuf, GIST_EXCLUSIVE);
     nsn = opaq->counter++
     UnlockReleaseBuffer(rootbuf)
     return nsn;
}

or perhaps we need to use locking mechanism for that, like just a new 
global lwlock or spinlock, to avoid deadlocks if someone is just 
splitting the root page. In any case, the fixed-sizedness of shared 
memory isn't an issue here.

- Heikki