Skip site navigation (1) Skip section navigation (2)

Re: Patch for circular buffer in tuplestore to optimize merge joins (v1)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: stark <stark(at)enterprisedb(dot)com>
Cc: pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Patch for circular buffer in tuplestore to optimize merge joins (v1)
Date: 2007-05-21 18:06:09
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-patches
stark <stark(at)enterprisedb(dot)com> writes:
> This patch implements a circular buffer in tuplestore which drops old tuples
> as they're no longer needed. It uses this for merge joins to avoid having to
> spill the tuplestore if no single value exceeds work_mem. It also is what's
> needed for both recursive query support and OLAP window functions (hence why
> it implements the more complex circular buffer rather than just moving the
> single tuple up to the head of the buffer).

Applied with revisions; mostly, that I took out the "circular buffer"
logic because I had no confidence in it.  It's a lot simpler to move the
remaining tuples down to the head of the array during tuplestore_trim.
And at least for the existing use-case, it's demonstrably useless to
have all the extra logic: there'll only be one tuple to move each time,
so it's cheaper to just do that.  When and if we have callers with
different usage patterns, we can measure whether it's worth trying to
avoid the memmove().  I'm dubious that it will be a win even then,
since the only way to have a lot of stuff to move is if you don't
trim very often.

			regards, tom lane

In response to

pgsql-patches by date

Next:From: Greg SmithDate: 2007-05-22 05:13:57
Subject: Re: COPY-able csv log outputs
Previous:From: Peter EisentrautDate: 2007-05-21 17:11:50
Subject: Re: xpath_array with namespaces support

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group