Re: [HACKERS] Get the offset of a tuple inside a table

2010-09-22 Thread Robert Haas
On Tue, Sep 21, 2010 at 10:58 PM, Pei He wrote: > Hi Tom, > The bitmapset works for me. > > I want to implement the operator for the following query: > > Select * from a left join b on a.id = b.id order by b.id; > > In a left outer join, I want the tuples that have matches in the inner table > app

Re: [HACKERS] Get the offset of a tuple inside a table

2010-09-21 Thread Pei He
Hi Tom, The bitmapset works for me. I want to implement the operator for the following query: Select * from a left join b on a.id = b.id order by b.id; In a left outer join, I want the tuples that have matches in the inner table appear first. So, the order by clause is need. If there is a index

Re: [HACKERS] Get the offset of a tuple inside a table

2010-09-21 Thread Tom Lane
Pei He writes: > What I want to do is, for a given key return the tuples that Index scan can > find, and return the rest tuples by a seq scan. So, I need to know which > tuples have been returned by maintain a bitmap, and to avoid return the same > tuple twice. > If I can know the offset of a tup

Re: [HACKERS] Get the offset of a tuple inside a table

2010-09-21 Thread Pei He
I doesn't realized postgresql can be such clever. Another problem I just found is after one tuple is deleted, there will be some slots unoccupied. The offset cannot be computed even know how much tuples a page can contain. I need one hash table. Thanks -- Pei On Tue, Sep 21, 2010 at 8:47 PM, Ke

Re: [HACKERS] Get the offset of a tuple inside a table

2010-09-21 Thread Kevin Grittner
Pei He wrote: > The offset is the order of a tuple in a Sequential Scan. That's not a safe assumption. Try starting a sequential scan against a large table on one connection; then before it finishes, start the same query on another connection. The second query joins the one already in progre

Re: [HACKERS] Get the offset of a tuple inside a table

2010-09-21 Thread Pei He
Hi Szymon, Kevin, The offset is the order of a tuple in a Sequential Scan. What I want to do is, for a given key return the tuples that Index scan can find, and return the rest tuples by a seq scan. So, I need to know which tuples have been returned by maintain a bitmap, and to avoid return the sa

Re: [HACKERS] Get the offset of a tuple inside a table

2010-09-21 Thread Kevin Grittner
Pei He wrote: > When I using an index scan, can I get the offset of the tuple in > the table? Well, regardless of the type of scan, you can select the ctid column, which gives the block number and the tuple number within the block. -Kevin -- Sent via pgsql-hackers mailing list (pgsql-hacke

Re: [HACKERS] Get the offset of a tuple inside a table

2010-09-21 Thread Szymon Guz
On 21 September 2010 23:02, Pei He wrote: > Hi, > When I using an index scan, can I get the offset of the tuple in the table? > > Thanks > -- > Pei > What do you mean by "the offset in the table"?

[HACKERS] Get the offset of a tuple inside a table

2010-09-21 Thread Pei He
Hi, When I using an index scan, can I get the offset of the tuple in the table? Thanks -- Pei