Re: [HACKERS] avoiding tuple copying in btree index builds

2014-07-01 Thread Robert Haas
On Tue, Jun 17, 2014 at 10:08 AM, Tom Lane wrote: > Robert Haas writes: >> On Mon, Jun 16, 2014 at 8:10 PM, Tom Lane wrote: >>> On a micro-optimization level, it might be worth passing the TID as >>> ItemPointer not ItemPointerData (ie, pass a pointer until we get to >>> the point of actually in

Re: [HACKERS] avoiding tuple copying in btree index builds

2014-06-17 Thread Tom Lane
Robert Haas writes: > On Mon, Jun 16, 2014 at 8:10 PM, Tom Lane wrote: >> On a micro-optimization level, it might be worth passing the TID as >> ItemPointer not ItemPointerData (ie, pass a pointer until we get to >> the point of actually inserting the TID into the index tuple). >> I'm not sure th

Re: [HACKERS] avoiding tuple copying in btree index builds

2014-06-17 Thread Robert Haas
On Mon, Jun 16, 2014 at 8:10 PM, Tom Lane wrote: > Robert Haas writes: >> On further review, this is definitely the way to go: it's a >> straight-up win. The isnull array is never more than one element in >> length, so testing the single element is quite trivial. The >> attached, revised patch

Re: [HACKERS] avoiding tuple copying in btree index builds

2014-06-16 Thread Tom Lane
Robert Haas writes: > On further review, this is definitely the way to go: it's a > straight-up win. The isnull array is never more than one element in > length, so testing the single element is quite trivial. The > attached, revised patch provides a modest but useful speedup for both > hash an

Re: [HACKERS] avoiding tuple copying in btree index builds

2014-06-16 Thread Robert Haas
On Tue, Jun 3, 2014 at 4:38 PM, Robert Haas wrote: > On Sun, Jun 1, 2014 at 3:26 AM, Amit Kapila wrote: >> On Tue, May 6, 2014 at 12:04 AM, Robert Haas wrote: >>> On Mon, May 5, 2014 at 2:13 PM, Andres Freund >>> wrote: >>> > On 2014-05-05 13:52:39 -0400, Robert Haas wrote: >>> >> Today, I disc

Re: [HACKERS] avoiding tuple copying in btree index builds

2014-06-07 Thread Amit Kapila
On Wed, Jun 4, 2014 at 2:08 AM, Robert Haas wrote: > On Sun, Jun 1, 2014 at 3:26 AM, Amit Kapila wrote: > > I also think it's possible to have similar optimization for hash index > > incase it has to spool the tuple for sorting. > > > > In function hashbuildCallback(), when buildstate->spool is

Re: [HACKERS] avoiding tuple copying in btree index builds

2014-06-03 Thread Robert Haas
On Sun, Jun 1, 2014 at 3:26 AM, Amit Kapila wrote: > On Tue, May 6, 2014 at 12:04 AM, Robert Haas wrote: >> On Mon, May 5, 2014 at 2:13 PM, Andres Freund >> wrote: >> > On 2014-05-05 13:52:39 -0400, Robert Haas wrote: >> >> Today, I discovered that when building a btree index, the btree code >>

Re: [HACKERS] avoiding tuple copying in btree index builds

2014-06-01 Thread Amit Kapila
On Tue, May 6, 2014 at 12:04 AM, Robert Haas wrote: > On Mon, May 5, 2014 at 2:13 PM, Andres Freund wrote: > > On 2014-05-05 13:52:39 -0400, Robert Haas wrote: > >> Today, I discovered that when building a btree index, the btree code > >> uses index_form_tuple() to create an index tuple from the

Re: [HACKERS] avoiding tuple copying in btree index builds

2014-05-05 Thread Robert Haas
On Mon, May 5, 2014 at 2:13 PM, Andres Freund wrote: > On 2014-05-05 13:52:39 -0400, Robert Haas wrote: >> Today, I discovered that when building a btree index, the btree code >> uses index_form_tuple() to create an index tuple from the heap tuple, >> calls tuplesort_putindextuple() to copy that t

Re: [HACKERS] avoiding tuple copying in btree index builds

2014-05-05 Thread Andres Freund
Hi, On 2014-05-05 13:52:39 -0400, Robert Haas wrote: > Today, I discovered that when building a btree index, the btree code > uses index_form_tuple() to create an index tuple from the heap tuple, > calls tuplesort_putindextuple() to copy that tuple into the sort's > memory context, and then frees

[HACKERS] avoiding tuple copying in btree index builds

2014-05-05 Thread Robert Haas
Hi, Today, I discovered that when building a btree index, the btree code uses index_form_tuple() to create an index tuple from the heap tuple, calls tuplesort_putindextuple() to copy that tuple into the sort's memory context, and then frees the original one it built. This seemed inefficient, so I