Re: Getting all entries in a single block with ctid - Mailing list pgsql-general

From Tomas Vondra
Subject Re: Getting all entries in a single block with ctid
Date
Msg-id be64327d326568a3be7fde1891ed34ff.squirrel@sq.gransy.com
Whole thread Raw
In response to Re: Getting all entries in a single block with ctid  (Tore Halvorsen <tore.halvorsen@gmail.com>)
Responses Re: Getting all entries in a single block with ctid  (Tore Halvorsen <tore.halvorsen@gmail.com>)
List pgsql-general
On 16 Leden 2012, 15:28, Tore Halvorsen wrote:
> On Mon, Jan 16, 2012 at 3:20 PM, Tomas Vondra <tv@fuzzy.cz> wrote:
> [...]
>
>>
>> WHERE ctid >= '(123,0)'::tid AND ctid < '(124,0)'::tid
>>
>>
> Ah, forgot a point here - without doing a sequential scan.

Hmmm, you could create an index on the ctid column, but that'd give you
bitmap index scan and not tid scan (which is probably what you're looking
for).

The only other solution is to check all possible items on the page. There
may be up to 291 items (although it depends on block size and
architecture, see MaxHeapTuplesPerPage in access/htup.h).

Something like this should work

 ctid = '(123,0)'::tid OR ctid = '(123,1)'::tid OR ctid = '(123,2)'::tid
OR ... OR ctid = '(123,290)'::tid

But maybe someone will recommend a better solution.

Tomas


pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: psql - TYPE DEFINITION
Next
From: Adrian Klaver
Date:
Subject: Re: time zone problem