Re: Threaded Sorting - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Threaded Sorting
Date
Msg-id 26334.1033762032@sss.pgh.pa.us
Whole thread Raw
In response to Re: Threaded Sorting  (Greg Copeland <greg@CopelandConsulting.Net>)
Responses Re: Threaded Sorting  (Greg Copeland <greg@CopelandConsulting.Net>)
List pgsql-hackers
Greg Copeland <greg@CopelandConsulting.Net> writes:
> ... I can understand why
> addressing the seemingly more common I/O bound case would receive
> priority, however, I'm at a loss as to why the other would be completely
> ignored.

Bruce already explained that we avoid threads because of portability and
robustness considerations.

The notion of a sort process pool seems possibly attractive.  I'm
unconvinced that it's going to be a win though because of the cost of
shoving data across address-space boundaries.  Another issue is that
the sort comparison function can be anything, including user-defined
code that does database accesses or other interesting stuff.  This
would mean that the sort auxiliary process would have to adopt the
database user identity of the originating process, and quite possibly
absorb a whole lot of other context information before it could
correctly/safely execute the comparison function.  That pushes the
overhead up a lot more.

(The need to allow arbitrary operations in the comparison function would
put a pretty substantial crimp on a thread-based approach, too, even if
we were willing to ignore the portability issue.)

Still, if you want to try it out, feel free ... this is an open-source
project, and if you can't convince other people that an idea is worth
implementing, that doesn't mean you can't implement it yourself and
prove 'em wrong.
        regards, tom lane


pgsql-hackers by date:

Previous
From: "Curtis Faith"
Date:
Subject: Re: Potential Large Performance Gain in WAL synching
Next
From: Greg Copeland
Date:
Subject: Re: Threaded Sorting