Re: [HACKERS] Free space management within heap page

2007-01-24 Thread Pavan Deolasee
On 1/24/07, Gregory Stark <[EMAIL PROTECTED]> wrote: "Pavan Deolasee" <[EMAIL PROTECTED]> writes: > On 1/24/07, Martijn van Oosterhout wrote: >> >> I thought the classical example was a transaction that updated the same >> tuple multiple times before committing. Then the version prior to the >

Re: [HACKERS] Free space management within heap page

2007-01-24 Thread Gregory Stark
"Pavan Deolasee" <[EMAIL PROTECTED]> writes: > On 1/24/07, Martijn van Oosterhout wrote: >> >> I thought the classical example was a transaction that updated the same >> tuple multiple times before committing. Then the version prior to the >> transaction start isn't dead yet, but all but one of t

Re: [HACKERS] Free space management within heap page

2007-01-24 Thread Pavan Deolasee
On 1/24/07, Martijn van Oosterhout wrote: On Wed, Jan 24, 2007 at 12:45:53PM +0530, Pavan Deolasee wrote: > My apologies if this has been discussed before. I went through the earlier > discussions, but its still very fuzzy to me. I am not able to construct a > case > where a tuple is DEAD (not

Re: [HACKERS] Free space management within heap page

2007-01-24 Thread Martijn van Oosterhout
On Wed, Jan 24, 2007 at 12:45:53PM +0530, Pavan Deolasee wrote: > My apologies if this has been discussed before. I went through the earlier > discussions, but its still very fuzzy to me. I am not able to construct a > case > where a tuple is DEAD (not RECENTLY_DEAD) and still there could be > a tr

Re: [HACKERS] Free space management within heap page

2007-01-23 Thread Pavan Deolasee
On 1/23/07, Tom Lane <[EMAIL PROTECTED]> wrote: "Pavan Deolasee" <[EMAIL PROTECTED]> writes: > I know it might break the ctid chain, but does that really matter ? Yes. You can't just decide that the tuple isn't needed anymore. As per other followup, you could possibly shrink a known-dead tuple

Re: [HACKERS] Free space management within heap page

2007-01-23 Thread Tom Lane
"Pavan Deolasee" <[EMAIL PROTECTED]> writes: > I know it might break the ctid chain, but does that really matter ? Yes. You can't just decide that the tuple isn't needed anymore. As per other followup, you could possibly shrink a known-dead tuple to just the header. The notion of keeping linked

Re: [HACKERS] Free space management within heap page

2007-01-23 Thread Pavan Deolasee
On 1/23/07, Heikki Linnakangas <[EMAIL PROTECTED]> wrote: ITAGAKI Takahiro wrote: > BLCKSZ is typically 8192 bytes and sizeof(ItemPointerData) is 4 bytes. > 1/4 comes from 8192 / 4 = 2048. If we allow zero-size tuples, the line > pointers area can bloat up to the ratio. We have tuples no less th

Re: [HACKERS] Free space management within heap page

2007-01-23 Thread Heikki Linnakangas
ITAGAKI Takahiro wrote: BLCKSZ is typically 8192 bytes and sizeof(ItemPointerData) is 4 bytes. 1/4 comes from 8192 / 4 = 2048. If we allow zero-size tuples, the line pointers area can bloat up to the ratio. We have tuples no less than 32 bytes-size, so the area is restricted 256 bytes now. size

Re: [HACKERS] Free space management within heap page

2007-01-23 Thread Heikki Linnakangas
Pavan Deolasee wrote: I thought that we can not reclaim the line pointers unless we remove the corresponding index entries as well. Isn't that the case ? If so, how would we reclaim the line pointers after the last used one ? There might be index pointers to dead line pointers in the proposed

Re: [HACKERS] Free space management within heap page

2007-01-23 Thread ITAGAKI Takahiro
Heikki Linnakangas <[EMAIL PROTECTED]> wrote: > > * Consider shrinking expired tuples to just their headers. > > Yeah, same idea. You suggested in that thread that we should keep the > headers because of line pointer bloat, but I don't see how that's > better. You're still going to get some li

Re: [HACKERS] Free space management within heap page

2007-01-23 Thread Pavan Deolasee
On 1/23/07, Heikki Linnakangas <[EMAIL PROTECTED]> wrote: Pavan Deolasee wrote: > So during a sequential or index scan, if a tuple is found to be dead, the > corresponding line pointer is marked "unused" and the space is returned > to a > free list. This free list is maintained within the page.

Re: [HACKERS] Free space management within heap page

2007-01-23 Thread Pavan Deolasee
On 1/23/07, Heikki Linnakangas <[EMAIL PROTECTED]> wrote: ITAGAKI Takahiro wrote: > Keeping only line pointers itself is not a problem, but it might lead > bloating of line pointers. If a particular tuple in a page is replaced > repeatedly, the line pointers area bloats up to 1/4 of the page.

Re: [HACKERS] Free space management within heap page

2007-01-23 Thread Heikki Linnakangas
ITAGAKI Takahiro wrote: "Pavan Deolasee" <[EMAIL PROTECTED]> wrote: The overwhelming vast majoirty of tuples are going to be in one or more indexes. Which means nearly all tuples are going to fall into this category. So where's the benefit? The line pointers can not reused, but the space consu

Re: [HACKERS] Free space management within heap page

2007-01-23 Thread Heikki Linnakangas
Pavan Deolasee wrote: I am thinking that maintaining fragmented free space within a heap page might be a good idea. It would help us to reuse the free space ASAP without waiting for a vacuum run on the page. This in turn will lead to lesser heap bloats and also increase the probability of placing

Re: [HACKERS] Free space management within heap page

2007-01-23 Thread Heikki Linnakangas
Pavan Deolasee wrote: One assumption I am making here is that its sufficient to mark the line pointer "unused" (reset LP_USED flag) even though there is an index entry pointing to the tuple. During index scan, we anyways check for ItemIdIsUsed() before proceeding further. I know it might break t

Re: [HACKERS] Free space management within heap page

2007-01-23 Thread ITAGAKI Takahiro
"Pavan Deolasee" <[EMAIL PROTECTED]> wrote: > > The overwhelming vast majoirty of tuples are going to be in one or more > > indexes. Which means nearly all tuples are going to fall into this > > category. So where's the benefit? > > The line pointers can not reused, but the space consumed by the

Re: [HACKERS] Free space management within heap page

2007-01-23 Thread Pavan Deolasee
On 1/23/07, Martijn van Oosterhout wrote: On Tue, Jan 23, 2007 at 01:48:08PM +0530, Pavan Deolasee wrote: > We might not be able to reuse the line pointers because indexes may have > references to it. All such line pointers will be freed when the page is > vacuumed during the regular vacuum.

Re: [HACKERS] Free space management within heap page

2007-01-23 Thread Martijn van Oosterhout
On Tue, Jan 23, 2007 at 01:48:08PM +0530, Pavan Deolasee wrote: > I am thinking that maintaining fragmented free space within a heap page > might be a good idea. It would help us to reuse the free space ASAP without > waiting for a vacuum run on the page. This in turn will lead to lesser heap > blo