RE: Scan by TID (was RE: [HACKERS] How to add a new build-in operator) - Mailing list pgsql-hackers

From Hiroshi Inoue
Subject RE: Scan by TID (was RE: [HACKERS] How to add a new build-in operator)
Date
Msg-id 000201bf13d1$1260f560$2801007e@cadzone.tpf.co.jp
Whole thread Raw
In response to Re: Scan by TID (was RE: [HACKERS] How to add a new build-in operator)  (Bruce Momjian <maillist@candle.pha.pa.us>)
Responses Re: Scan by TID (was RE: [HACKERS] How to add a new build-in operator)  (Bruce Momjian <maillist@candle.pha.pa.us>)
List pgsql-hackers
> 
> > > > I'm planning to implement a new type of scan,scan by TID.
> > > > It's on TODO      * Allow WHERE restriction on ctid.
> > > > First,I want to define an equal operator between TID.
> > >

[snip] 

> 
> > I would use OIDs for '=' operator between TIDs as follows.
> >     387    for = (tid, tid)
> >     1292    for tideq(tid, tid)
> > 
> > 
> > Unfortunately,TIDs are changed by UPDATE operations.
> > So we would need some functions in order to get the latest
> > TID of a specified tuple such as
> >      currtid(relationid/name, tid) which returns tid.
> > I would provide functions for both relid and relname and
> > use 1293-1294 for OIDs of these functions.
> > 
> > Comments ?
> > If there's no objection,I would commit them to the current tree.
> 
> Sounds good.
>

I have committed them to the current tree.
Needs initdb.

Now we could enjoy WHERE restriction on ctid as follows.
Unfortunately,the scan is still sequential. 

=> create table t1 (dt text);
CREATE
=> insert into t1 values ('data inserted');
INSERT 45833 1
=> select ctid,* from t1;
ctid |dt
-----+----------
(0,1)|data inserted
(1 row)

=> select * from t1 where ctid='(0,1)';
dt
----------
data inserted
(1 row)

=> update t1 set dt='data updated';
UPDATE 1
=> select * from t1 where ctid='(0,1)';
dt
--
(0 rows)

=> select ctid,* from t1 where ctid=currtid2('t1', '(0,1)');
ctid |dt
-----+------------
(0,2)|data updated
(1 row) 

Regards.

Hiroshi Inoue
Inoue@tpf.co.jp


pgsql-hackers by date:

Previous
From: Oleg Bartunov
Date:
Subject: vaccum problem
Next
From: wieck@debis.com (Jan Wieck)
Date:
Subject: Re: [HACKERS] Interesting Quote you might enjoy about PGSQL.