Re: Ordered Append Node - Mailing list pgsql-hackers

From Csaba Nagy
Subject Re: Ordered Append Node
Date
Msg-id 1195823021.27060.114.camel@PCD12478
Whole thread Raw
In response to Re: Ordered Append Node  (Gregory Stark <stark@enterprisedb.com>)
List pgsql-hackers
On Fri, 2007-11-23 at 12:36 +0000, Gregory Stark wrote:
> I also did an optimization similar to the bounded-sort case where we check if
> the next tuple from the same input which last contributed the result record
> comes before the top element of the heap. That avoids having to do an insert
> and siftup only to pull out the same record you just inserted. In theory this
> is not an optimization but in practice I think partitioned tables will often
> contain contiguous blocks of key values and queries will often be joining
> against that key and therefore often want to order by it.

If it is an option, you could also do this by a new method on the heap
which adds a new entry and removes the resulting new head in one atomic
operation. That would work with one single comparison for the less than
current head situation, and it would not need to repeat that comparison
if that fails. Also it could directly remove the head and balance the
tree in one go.

Cheers,
Csaba.




pgsql-hackers by date:

Previous
From: Gregory Stark
Date:
Subject: Re: Ordered Append Node
Next
From: Markus Schiltknecht
Date:
Subject: Re: Ordered Append Node