Re: Getting all entries in a single block with ctid

From: "Tomas Vondra" <tv(at)fuzzy(dot)cz>
To: "Tore Halvorsen" <tore(dot)halvorsen(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Getting all entries in a single block with ctid
Date: 2012-01-16 15:08:29
Message-ID: be64327d326568a3be7fde1891ed34ff.squirrel@sq.gransy.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 16 Leden 2012, 15:28, Tore Halvorsen wrote:
> On Mon, Jan 16, 2012 at 3:20 PM, Tomas Vondra <tv(at)fuzzy(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2012-01-16 15:28:59 Re: time zone problem
Previous Message Adrian Klaver 2012-01-16 14:52:39 Re: psql - TYPE DEFINITION