From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Dave Trombley <dtrom(at)bumba(dot)net> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: OIDs as object handles? |
Date: | 2001-12-30 17:29:09 |
Message-ID: | 340.1009733349@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Dave Trombley <dtrom(at)bumba(dot)net> writes:
> There is a particular feature I find myself wanting: Given a
> table row, I'd like a handle to that row in storage so that I may access
> it again quickly (ie. without the overhead of a SELECT).
There isn't any such thing as a "handle to that row in storage",
primarily because there's no guarantee that the row is in memory at
all. You could, however, use the row's ctid (physical location) to
access it quickly.
select ctid, ... from table where <conditions>;
...
select ... from table where ctid = 'value';
I'd only recommend that you do this within a transaction block, so that
you can be certain that the row doesn't get deleted or updated between
the two selects. Otherwise there's the possibility of retrieving no
row, or even the wrong row at the second select.
> Also, could someone explain the following (possibly related)
> error?
The rowtype-as-column functionality doesn't work; I'm not certain that
it ever has worked, at least not in the way you expect. AFAICT, the
original Berkeley implementation involved expecting to find the OID of
a *function*, not a row, in the stored column value --- this function
would be executed to get the row(s) represented. This might still work
if you cared to set it up, but I wouldn't be surprised to find it
suffering from bit rot.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2001-12-30 19:16:34 | Re: OIDs as object handles? |
Previous Message | Dave Trombley | 2001-12-30 05:34:46 | OIDs as object handles? |