Re: [PATCH] Incremental sort (was: PoC: Partial sort)

From: James Coleman <jtc331(at)gmail(dot)com>
To: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Rafia Sabih <rafia(dot)pghackers(at)gmail(dot)com>, Peter Geoghegan <pg(at)bowt(dot)ie>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Shaun Thomas <shaun(dot)thomas(at)2ndquadrant(dot)com>, Dmitry Dolgov <9erthalion6(at)gmail(dot)com>, Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Subject: Re: [PATCH] Incremental sort (was: PoC: Partial sort)
Date: 2020-03-13 17:16:44
Message-ID: CAAaqYe-AMOQ9Rr_zcGtNXfAaMj9sT6mGCp_M0tJbQeuLsms-Rw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Mar 10, 2020 at 10:44 PM Tomas Vondra
<tomas(dot)vondra(at)2ndquadrant(dot)com> wrote:
...
> Now, a couple comments about parts 0001 - 0003 of the patch ...
>
> 1) I see a bunch of failures in the regression test, due to minor
> differences in the explain output. All the differences are about minor
> changes in memory usage, like this:
>
> - "Sort Space Used": 30, +
> + "Sort Space Used": 29, +
>
> I'm not sure if it happens on my machine only, but maybe the test is not
> entirely stable.

make check passes on multiple machines for me; what arch/distro are you using?

Is there a better way to test these? I would prefer these code paths
have test coverage, but the standard SQL tests don't leave a good way
to handle stuff like this.

Is TAP the only alternative, and do you think it'd be worth considering?

> 2) I think this bit in ExecReScanIncrementalSort is wrong:
>
> node->sort_Done = false;
> tuplesort_end(node->fullsort_state);
> node->prefixsort_state = NULL;
> tuplesort_end(node->fullsort_state);
> node->prefixsort_state = NULL;
> node->bound_Done = 0;
>
> Notice both places reset fullsort_state and set prefixsort_state to
> NULL. Another thing is that I'm not sure it's fine to pass NULL to
> tuplesort_end (my guess is tuplesort_free will fail when it gets NULL).

Fixed.

James

Attachment Content-Type Size
v36-0001-Consider-low-startup-cost-when-adding-partial-pa.patch application/octet-stream 3.2 KB
v36-0003-Consider-incremental-sort-paths-in-additional-pl.patch application/octet-stream 13.1 KB
v36-0002-Implement-incremental-sort.patch application/octet-stream 149.7 KB
v36-0004-A-couple-more-places-for-incremental-sort.patch application/octet-stream 8.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2020-03-13 17:27:07 Re: explain HashAggregate to report bucket and memory stats
Previous Message Jeff Davis 2020-03-13 17:15:46 Re: explain HashAggregate to report bucket and memory stats