Re: [PATCH] explain sortorder

Lists: pgsql-hackers
From: "Timmer, Marius" <marius(dot)timmer(at)uni-muenster(dot)de>
To: pgsql-hackerspostgresqlorg <pgsql-hackers(at)postgresql(dot)org>
Subject: [PATCH] explain sortorder
Date: 2014-11-25 13:03:23
Message-ID: F4FF595C-D39D-4036-A446-57C91ABE6B31@exchange.wwu.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello everyone,

For creating indexes on more than one column, it is useful to know the sort
order of each sort key. So now, if you run EXPLAIN in VERBOSE mode, you get
the sort order information in the order the sort keys are displayed - Lukas

- This patch is meant for discussion
- It’s against the master branch
- The patch compiles successfully and one test (inherit) is affected
- There are no platform-specific items in this patch
- The patch, as described, enhances EXPLAIN VERBOSE. For an example, see
the regression test
- There is no TODO item referring to this patch

@patchname: explain_sortorder v2
@version: 2.01
@author: Marius Timmer <mtimm_01(at)uni-muenster(dot)de>,
Arne Scheffer <arne(dot)scheffer(at)uni-muenster(dot)de>,
Lukas Kreft <lukaskreft(at)uni-muenster(dot)de>
@description: Display sort order options in VERBOSE mode of EXPLAIN

- The situation

Currently I am able to run a EXPLAIN-Statement (verbose) for getting more
Information about a Query. But it is not enough to check in which order the
results will be sorted, what could be interesting to modify some Statements
so they can become more performant.

- What this patch does

This patch will add one more information to the result of an EXPLAIN-
Statement in verbose-mode. You will find the new property "Sort order"
which tells you the order of the used keys while sorting.
You can use it in all available Formats.

Greetings,

Marius Timmer

Attachment Content-Type Size
explain_sortorder-v2.patch application/octet-stream 15.3 KB
unknown_filename text/plain 142 bytes
smime.p7s application/pkcs7-signature 4.7 KB

From: Mike Blackwell <mike(dot)blackwell(at)rrd(dot)com>
To: "Timmer, Marius" <marius(dot)timmer(at)uni-muenster(dot)de>
Cc: pgsql-hackerspostgresqlorg <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] explain sortorder
Date: 2014-12-15 16:49:23
Message-ID: CANPAkgsKtPxLGF_Xx_p20B-5gb98BvCYqy9FrjzLD6RTbdPD8g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Initial review:

Patch applies cleanly to current head, although it appears to have
soft/hard tab and trailing space issues.

make check fails with the output below. The expected collation clause is
not present.

--
-- Test explain feature: sort order
--
CREATE TABLE sortordertest (n1 char(1), n2 int4);
-- Insert values by which should be ordered
INSERT INTO sortordertest(n1, n2) VALUES ('d', 5), ('b', 3), ('a', 1),
('e', 2), ('c', 4);
-- Display sort order when explain analyze and verbose are true.
EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM sortordertest ORDER BY n1
COLLATE "C" DESC, n2;
QUERY PLAN
------------------------------------------------
Sort
Output: n1, n2, ((n1)::character(1))
Sort Key: sortordertest.n1, sortordertest.n2
Sort Order: ASC NULLS LAST, ASC NULLS LAST
-> Seq Scan on public.sortordertest
Output: n1, n2, n1
(6 rows)

DROP TABLE sortordertest;

__________________________________________________________________________________
*Mike Blackwell | Technical Analyst, Distribution Services/Rollout
Management | RR Donnelley*
1750 Wallace Ave | St Charles, IL 60174-3401
Office: 630.313.7818
Mike(dot)Blackwell(at)rrd(dot)com
http://www.rrdonnelley.com


From: "Timmer, Marius" <marius(dot)timmer(at)uni-muenster(dot)de>
To: Mike Blackwell <mike(dot)blackwell(at)rrd(dot)com>
Cc: pgsql-hackerspostgresqlorg <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] explain sortorder
Date: 2014-12-16 09:52:13
Message-ID: 47F25AA0-77BA-4B85-B675-C8C9E5168CF3@exchange.wwu.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi Mike,

Now I've replaced the spaces at the beginning of the lines with tabs.
Quotes(") in the expected/explain_sortorder.out-File caused failing „make check“. So I changed them to single quotes(').

I’ve added the corrected patch as attachment.

Kind regards,

Marius

Attachment Content-Type Size
explain_sortorder-v3.patch application/octet-stream 23.8 KB
unknown_filename text/plain 116 bytes
smime.p7s application/pkcs7-signature 4.7 KB

From: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
To: "Timmer, Marius" <marius(dot)timmer(at)uni-muenster(dot)de>
Cc: Mike Blackwell <mike(dot)blackwell(at)rrd(dot)com>, pgsql-hackerspostgresqlorg <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] explain sortorder
Date: 2014-12-17 15:34:49
Message-ID: 5491A299.5060904@vmware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 12/15/2014 06:49 PM, Mike Blackwell wrote:
> QUERY PLAN
> ------------------------------------------------
> Sort
> Output: n1, n2, ((n1)::character(1))
> Sort Key: sortordertest.n1, sortordertest.n2
> Sort Order: ASC NULLS LAST, ASC NULLS LAST
> -> Seq Scan on public.sortordertest
> Output: n1, n2, n1
> (6 rows)

I don't like this output. If there are a lot of sort keys, it gets
difficult to match the right ASC/DESC element to the sort key it applies
to. (Also, there seems to be double-spaces in the list)

I would suggest just adding the information to the Sort Key line. As
long as you don't print the modifiers when they are defaults (ASC and
NULLS LAST), we could print the information even in non-VERBOSE mode. So
it would look something like:

Sort Key: sortordertest.n1 NULLS FIRST, sortordertest.n2 DESC

- Heikki


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
Cc: "Timmer, Marius" <marius(dot)timmer(at)uni-muenster(dot)de>, Mike Blackwell <mike(dot)blackwell(at)rrd(dot)com>, pgsql-hackerspostgresqlorg <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] explain sortorder
Date: 2014-12-17 15:42:57
Message-ID: 7441.1418830977@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> writes:
> I would suggest just adding the information to the Sort Key line. As
> long as you don't print the modifiers when they are defaults (ASC and
> NULLS LAST), we could print the information even in non-VERBOSE mode.

+1. I had assumed without looking that that was what it did already,
else I'd have complained too.

regards, tom lane


From: "Timmer, Marius" <marius(dot)timmer(at)uni-muenster(dot)de>
To: pgsql-hackerspostgresqlorg <pgsql-hackers(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, "Mike Blackwell" <mike(dot)blackwell(at)rrd(dot)com>
Subject: Re: [PATCH] explain sortorder
Date: 2015-01-07 16:17:50
Message-ID: 6004A939-59B5-4454-B92C-910A795D901B@exchange.wwu.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

we have spent the last days to realize your suggestions in the patch.
It affects the result of a EXPLAIN-Statement (even in non-verbose-mode). Now you will get the order-information for every single sort-key which is not ordered by the defaults.

best regards,

Marius

---
Marius Timmer
Zentrum für Informationsverarbeitung
Westfälische Wilhelms-Universität Münster
Einsteinstraße 60

mtimm_01(at)uni-muenster(dot)de

Attachment Content-Type Size
explain_sortorder-v6.patch application/octet-stream 10.7 KB

From: Mike Blackwell <mike(dot)blackwell(at)rrd(dot)com>
To: "Timmer, Marius" <marius(dot)timmer(at)uni-muenster(dot)de>
Cc: pgsql-hackerspostgresqlorg <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] explain sortorder
Date: 2015-01-07 18:51:49
Message-ID: CANPAkgvGG2LgRrvc6CtAZrwX7nGe6R6pXdJ6vc9bBMBtE6nnRQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

V6 of this patch applies, builds and checks against the current HEAD. The
areas below could use some attention.

In explain.c:

malloc() should not be called directly here. palloc() would be the
correct call, I believe, but the functions in stringinfo.h are probably
your best choice as they remove the necessity for dealing with buffer size
and overflow.

There is leftover commented out code from the previous patch version in
the T_Sort case.

In show_sort_group_keys(), the splitting of the existing declaration and
initialization of the keyresno and target seems unnecessary and against the
style of surrounding code.

Multi-line comments should follow the existing format.

There are no tests for the "... is LC_COLLATE" and "COLLATE..." cases.

Section 14.1 of the documentation may need to be updated.

Mike.

__________________________________________________________________________________
*Mike Blackwell | Technical Analyst, Distribution Services/Rollout
Management | RR Donnelley*
1750 Wallace Ave | St Charles, IL 60174-3401
Office: 630.313.7818
Mike(dot)Blackwell(at)rrd(dot)com
http://www.rrdonnelley.com

<http://www.rrdonnelley.com/>
* <Mike(dot)Blackwell(at)rrd(dot)com>*

On Wed, Jan 7, 2015 at 10:17 AM, Timmer, Marius <
marius(dot)timmer(at)uni-muenster(dot)de> wrote:

> Hi,
>
> we have spent the last days to realize your suggestions in the patch.
> It affects the result of a EXPLAIN-Statement (even in non-verbose-mode).
> Now you will get the order-information for every single sort-key which is
> not ordered by the defaults.
>
>
> best regards,
>
> Marius
>
>
>
>
> ---
> Marius Timmer
> Zentrum für Informationsverarbeitung
> Westfälische Wilhelms-Universität Münster
> Einsteinstraße 60
>
> mtimm_01(at)uni-muenster(dot)de
>


From: "Timmer, Marius" <marius(dot)timmer(at)uni-muenster(dot)de>
To: pgsql-hackerspostgresqlorg <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] explain sortorder
Date: 2015-01-13 16:04:49
Message-ID: C0983E73-EE08-43A4-9CB5-32B22729BAF6@exchange.wwu.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

we removed
-malloc() (StringInfo is used as suggested now).
-leftover commented out code
-the splitting of existing declaration and initialization in show_group_keys().

Missing tests and documentation are WIP and will follow with the next patch version.

Best regards

Marius

---
Marius Timmer
Zentrum für Informationsverarbeitung
Westfälische Wilhelms-Universität Münster
Einsteinstraße 60

mtimm_01(at)uni-muenster(dot)de

Attachment Content-Type Size
explain_sortorder-v7.patch application/octet-stream 24.9 KB

From: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
To: "Timmer, Marius" <marius(dot)timmer(at)uni-muenster(dot)de>, pgsql-hackerspostgresqlorg <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] explain sortorder
Date: 2015-01-13 17:52:50
Message-ID: 54B55B72.3050805@vmware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 01/13/2015 06:04 PM, Timmer, Marius wrote:
> -malloc() (StringInfo is used as suggested now).

There really shouldn't be any snprintf() calls in the patch, when
StringInfo is used correctly...

> @@ -1187,6 +1187,7 @@ explain (verbose, costs off) select * from matest0 order by 1-id;
> Sort
> Output: matest0.id, matest0.name, ((1 - matest0.id))
> Sort Key: ((1 - matest0.id))
> + Sort Order: ASC NULLS LAST
> -> Result
> Output: matest0.id, matest0.name, (1 - matest0.id)
> -> Append

This patch isn't going to be committed with this output format. Please
change per my suggestion earlier:

> I don't like this output. If there are a lot of sort keys, it gets
> difficult to match the right ASC/DESC element to the sort key it applies
> to. (Also, there seems to be double-spaces in the list)
>
> I would suggest just adding the information to the Sort Key line. As
> long as you don't print the modifiers when they are defaults (ASC and
> NULLS LAST), we could print the information even in non-VERBOSE mode. So
> it would look something like:
>
> Sort Key: sortordertest.n1 NULLS FIRST, sortordertest.n2 DESC

Or if you don't agree with that, explain why.

- Heikki


From: "Timmer, Marius" <marius(dot)timmer(at)uni-muenster(dot)de>
To: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
Cc: "Timmer, Marius" <marius(dot)timmer(at)uni-muenster(dot)de>, pgsql-hackerspostgresqlorg <pgsql-hackers(at)postgresql(dot)org>, Arne Scheffer <scheffa(at)uni-muenster(dot)de>
Subject: Re: [PATCH] explain sortorder
Date: 2015-01-14 15:26:02
Message-ID: 175EB07D-E647-4749-96FA-F3BBC688B82D@exchange.wwu.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello Heikki,

abbreviated version:
Sorry, the problem is only the unhandy patch text format, not different opinions how to proceed.

Long version:
The v7 patch file already addressed your suggestions,
but the file contained serveral (old) local commits,
the new ones at the end of the patch text/file.

v7.1 is attached and addresses this issue providing a clean patch file.

V8 will - as mentioned - add missing docs and regression tests,
Mike suggested.

VlG-Arne & Marius

---
Marius Timmer
Zentrum für Informationsverarbeitung
Westfälische Wilhelms-Universität Münster
Einsteinstraße 60

mtimm_01(at)uni-muenster(dot)de

Am 13.01.2015 um 18:52 schrieb Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>:

> On 01/13/2015 06:04 PM, Timmer, Marius wrote:
>> -malloc() (StringInfo is used as suggested now).
>
> There really shouldn't be any snprintf() calls in the patch, when StringInfo is used correctly...
>
>> @@ -1187,6 +1187,7 @@ explain (verbose, costs off) select * from matest0 order by 1-id;
>> Sort
>> Output: matest0.id, matest0.name, ((1 - matest0.id))
>> Sort Key: ((1 - matest0.id))
>> + Sort Order: ASC NULLS LAST
>> -> Result
>> Output: matest0.id, matest0.name, (1 - matest0.id)
>> -> Append
>
> This patch isn't going to be committed with this output format. Please change per my suggestion earlier:
>
>> I don't like this output. If there are a lot of sort keys, it gets
>> difficult to match the right ASC/DESC element to the sort key it applies
>> to. (Also, there seems to be double-spaces in the list)
>>
>> I would suggest just adding the information to the Sort Key line. As
>> long as you don't print the modifiers when they are defaults (ASC and
>> NULLS LAST), we could print the information even in non-VERBOSE mode. So
>> it would look something like:
>>
>> Sort Key: sortordertest.n1 NULLS FIRST, sortordertest.n2 DESC
>
> Or if you don't agree with that, explain why.
>
> - Heikki
>

Attachment Content-Type Size
explain_sortorder-v7_1.patch application/octet-stream 11.5 KB

From: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
To: "Timmer, Marius" <marius(dot)timmer(at)uni-muenster(dot)de>
Cc: pgsql-hackerspostgresqlorg <pgsql-hackers(at)postgresql(dot)org>, Arne Scheffer <scheffa(at)uni-muenster(dot)de>
Subject: Re: [PATCH] explain sortorder
Date: 2015-01-14 15:30:55
Message-ID: 54B68BAF.1010808@vmware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 01/14/2015 05:26 PM, Timmer, Marius wrote:
> Hello Heikki,
>
> abbreviated version:
> Sorry, the problem is only the unhandy patch text format, not different opinions how to proceed.
>
> Long version:
> The v7 patch file already addressed your suggestions,
> but the file contained serveral (old) local commits,
> the new ones at the end of the patch text/file.

Ah, missed that. I stopped reading when I saw the old stuff there :-).

> v7.1 is attached and addresses this issue providing a clean patch file.

Ok, thanks, will take a look.

> V8 will - as mentioned - add missing docs and regression tests,

Great!

- Heikki


From: Arne Scheffer <scheffa(at)uni-muenster(dot)de>
To: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
Cc: "Timmer, Marius" <marius(dot)timmer(at)uni-muenster(dot)de>, pgsql-hackerspostgresqlorg <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] explain sortorder
Date: 2015-01-14 16:42:29
Message-ID: alpine.DEB.2.02.1501141731430.3444@zivarne
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

we will also remove the following is lc_collate hint in the next version, showing only mandatory info as suggested.

/* for those who use COLLATE although their default is already the wanted */
if (strcmp(collname, localeptr) == 0)
{
appendStringInfo(sortorderInformation, " (%s is LC_COLLATE)", collname);
}

Anybody insisting on that?

Arne

Note: I see, at the moment we use the wrong default for DESC. We'll fix that.

On Wed, 14 Jan 2015, Heikki Linnakangas wrote:

> On 01/14/2015 05:26 PM, Timmer, Marius wrote:
>> Hello Heikki,
>>
>> abbreviated version:
>> Sorry, the problem is only the unhandy patch text format, not different
>> opinions how to proceed.
>>
>> Long version:
>> The v7 patch file already addressed your suggestions,
>> but the file contained serveral (old) local commits,
>> the new ones at the end of the patch text/file.
>
> Ah, missed that. I stopped reading when I saw the old stuff there :-).
>
>> v7.1 is attached and addresses this issue providing a clean patch file.
>
> Ok, thanks, will take a look.
>
>> V8 will - as mentioned - add missing docs and regression tests,
>
> Great!
>
> - Heikki
>
>


From: "Timmer, Marius" <marius(dot)timmer(at)uni-muenster(dot)de>
To: Arne Scheffer <scheffa(at)uni-muenster(dot)de>
Cc: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, "Timmer, Marius" <marius(dot)timmer(at)uni-muenster(dot)de>, pgsql-hackerspostgresqlorg <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] explain sortorder
Date: 2015-01-15 15:05:54
Message-ID: 68A3685D-858C-4EE0-BC59-73447EC49C43@exchange.wwu.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

attached is version 8, fixing remaining issues, adding docs and tests as requested/agreed.

Marius & Arne

---
Marius Timmer
Zentrum für Informationsverarbeitung
Westfälische Wilhelms-Universität Münster
Einsteinstraße 60

mtimm_01(at)uni-muenster(dot)de

Am 14.01.2015 um 17:42 schrieb Arne Scheffer <scheffa(at)uni-muenster(dot)de>:

> Hi,
>
> we will also remove the following is lc_collate hint in the next version, showing only mandatory info as suggested.
>
> /* for those who use COLLATE although their default is already the wanted */
> if (strcmp(collname, localeptr) == 0)
> {
> appendStringInfo(sortorderInformation, " (%s is LC_COLLATE)", collname);
> }
>
> Anybody insisting on that?
>
> Arne
>
> Note: I see, at the moment we use the wrong default for DESC. We'll fix that.
>
> On Wed, 14 Jan 2015, Heikki Linnakangas wrote:
>
>> On 01/14/2015 05:26 PM, Timmer, Marius wrote:
>>> Hello Heikki,
>>> abbreviated version:
>>> Sorry, the problem is only the unhandy patch text format, not different opinions how to proceed.
>>> Long version:
>>> The v7 patch file already addressed your suggestions,
>>> but the file contained serveral (old) local commits,
>>> the new ones at the end of the patch text/file.
>>
>> Ah, missed that. I stopped reading when I saw the old stuff there :-).
>>
>>> v7.1 is attached and addresses this issue providing a clean patch file.
>>
>> Ok, thanks, will take a look.
>>
>>> V8 will - as mentioned - add missing docs and regression tests,
>>
>> Great!
>>
>> - Heikki
>>
>>

Attachment Content-Type Size
explain_sortorder-v8.patch application/octet-stream 14.3 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Timmer, Marius" <marius(dot)timmer(at)uni-muenster(dot)de>
Cc: Arne Scheffer <scheffa(at)uni-muenster(dot)de>, Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, pgsql-hackerspostgresqlorg <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] explain sortorder
Date: 2015-01-15 17:14:39
Message-ID: 15879.1421342079@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"Timmer, Marius" <marius(dot)timmer(at)uni-muenster(dot)de> writes:
> attached is version 8, fixing remaining issues, adding docs and tests as requested/agreed.

I'll pick this up --- I've been a bit lax about helping with this
commitfest.

regards, tom lane


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Timmer, Marius" <marius(dot)timmer(at)uni-muenster(dot)de>
Cc: Arne Scheffer <scheffa(at)uni-muenster(dot)de>, Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, pgsql-hackerspostgresqlorg <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] explain sortorder
Date: 2015-01-16 23:45:07
Message-ID: 28519.1421451907@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"Timmer, Marius" <marius(dot)timmer(at)uni-muenster(dot)de> writes:
> attached is version 8, fixing remaining issues, adding docs and tests as requested/agreed.

I've committed this with some rather substantial alterations, notably:

* Having get_sortorder_by_keyno dig into the plan state node by itself
seemed like a bad idea; it's certainly at variance with the existing
division of knowledge in this code, and I think it might outright do
the wrong thing if there's a Sort node underneath an Agg or Group node
(since in those cases the child Sort node, not the parent node, would
get passed in). I fixed it so that show_sort_keys and siblings are
responsible for extracting and passing in the correct data arrays.

* There were some minor bugs in the rules for when to print NULLS
FIRST/LAST too. I think the way I've got it now is a precise inverse of
what addTargetToSortList() will do.

* The proposed new regression test cases were not portable ("en_US"
isn't guaranteed to exist), and I thought adding a new regression
script file for just one test was a bit excessive. The DESC and
USING behaviors were already covered by existing test cases so I just
added something to exercise COLLATE and NULLS FIRST in collate.sql.

* I took out the change in perform.sgml. The change as proposed was
seriously confusing because it injected off-topic discussion into an
example that was meant to be just about the additional information printed
by EXPLAIN ANALYZE. I'm not really sure that this feature needs any
specific documentation (other than its eventual mention in the release
notes); but if it does, we should probably add a brand new example
someplace before the EXPLAIN ANALYZE subsection.

* Assorted cleanups such as removal of irrelevant whitespace changes.
That sort of thing just makes a reviewer's job harder, so it's best
to avoid it if you can.

regards, tom lane


From: "Timmer, Marius" <marius(dot)timmer(at)uni-muenster(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Timmer, Marius" <marius(dot)timmer(at)uni-muenster(dot)de>, Arne Scheffer <scheffa(at)uni-muenster(dot)de>, Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, pgsql-hackerspostgresqlorg <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] explain sortorder
Date: 2015-01-19 10:13:45
Message-ID: B19C7513-4DA6-4A36-B909-194606DF37CE@exchange.wwu.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi Tom,

we are very happy seeing this committed.
Thank you for committing and Mike for the review!!

Your changes make sense to us, except one question:

We think, you wanted to switch to DESC behavior
(print out NULLS FIRST) in cases, where
„USING“ uses an operator which is considered to be
a DESC operator.
Great, we missed that.

But get_equality_op_for_ordering_op is called in
cases, where reverse is false, but
the part

if (reverse)
*reverse = (strategy == BTGreaterStrategyNumber);

never changes this to true?

VlG

Marius & Arne

---
Marius Timmer
Arne Scheffer
Zentrum für Informationsverarbeitung
Westfälische Wilhelms-Universität Münster
Einsteinstraße 60

mtimm_01(at)uni-muenster(dot)de

Am 17.01.2015 um 00:45 schrieb Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:

> "Timmer, Marius" <marius(dot)timmer(at)uni-muenster(dot)de> writes:
>> attached is version 8, fixing remaining issues, adding docs and tests as requested/agreed.
>
> I've committed this with some rather substantial alterations, notably:
>
> * Having get_sortorder_by_keyno dig into the plan state node by itself
> seemed like a bad idea; it's certainly at variance with the existing
> division of knowledge in this code, and I think it might outright do
> the wrong thing if there's a Sort node underneath an Agg or Group node
> (since in those cases the child Sort node, not the parent node, would
> get passed in). I fixed it so that show_sort_keys and siblings are
> responsible for extracting and passing in the correct data arrays.
>
> * There were some minor bugs in the rules for when to print NULLS
> FIRST/LAST too. I think the way I've got it now is a precise inverse of
> what addTargetToSortList() will do.
>
> * The proposed new regression test cases were not portable ("en_US"
> isn't guaranteed to exist), and I thought adding a new regression
> script file for just one test was a bit excessive. The DESC and
> USING behaviors were already covered by existing test cases so I just
> added something to exercise COLLATE and NULLS FIRST in collate.sql.
>
> * I took out the change in perform.sgml. The change as proposed was
> seriously confusing because it injected off-topic discussion into an
> example that was meant to be just about the additional information printed
> by EXPLAIN ANALYZE. I'm not really sure that this feature needs any
> specific documentation (other than its eventual mention in the release
> notes); but if it does, we should probably add a brand new example
> someplace before the EXPLAIN ANALYZE subsection.
>
> * Assorted cleanups such as removal of irrelevant whitespace changes.
> That sort of thing just makes a reviewer's job harder, so it's best
> to avoid it if you can.
>
> regards, tom lane


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Timmer, Marius" <marius(dot)timmer(at)uni-muenster(dot)de>
Cc: Arne Scheffer <scheffa(at)uni-muenster(dot)de>, Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, pgsql-hackerspostgresqlorg <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] explain sortorder
Date: 2015-01-19 16:09:34
Message-ID: 27093.1421683774@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"Timmer, Marius" <marius(dot)timmer(at)uni-muenster(dot)de> writes:
> We think, you wanted to switch to DESC behavior
> (print out NULLS FIRST) in cases, where
> USING uses an operator which is considered to be
> a DESC operator.

Right, because that's how addTargetToSortList() would parse it.

> But get_equality_op_for_ordering_op is called in
> cases, where reverse is false, but
> the part
> if (reverse)
> *reverse = (strategy == BTGreaterStrategyNumber);
> never changes this to true?

Sorry, not following? It's true that what I added to explain.c doesn't
worry too much about the possibility of get_ordering_op_properties()
failing --- that really shouldn't happen for something that was previously
accepted as a sorting operator. But if it does, "reverse" will just be
left as false, so the behavior will anyway be unsurprising I think.
We could alternatively make it throw a "cache lookup failed" error but
I'm not sure how that makes anyone's life better.

regards, tom lane


From: Mike Blackwell <mike(dot)blackwell(at)rrd(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Timmer, Marius" <marius(dot)timmer(at)uni-muenster(dot)de>, Arne Scheffer <scheffa(at)uni-muenster(dot)de>, Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, pgsql-hackerspostgresqlorg <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] explain sortorder
Date: 2015-01-19 16:41:28
Message-ID: CANPAkgtF-YLKo_u1XxYX8gSvhzHmC4uD8au-V4iu7-xO+zAxjg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom,

Thanks for the comments on what you ended up changing. It helps point out
the kind of things I should be looking for. I'll try to let less slip
through in the future.

Mike

__________________________________________________________________________________
*Mike Blackwell | Technical Analyst, Distribution Services/Rollout
Management | RR Donnelley*
1750 Wallace Ave | St Charles, IL 60174-3401
Office: 630.313.7818
Mike(dot)Blackwell(at)rrd(dot)com
http://www.rrdonnelley.com

<http://www.rrdonnelley.com/>
* <Mike(dot)Blackwell(at)rrd(dot)com>*

On Mon, Jan 19, 2015 at 10:09 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> "Timmer, Marius" <marius(dot)timmer(at)uni-muenster(dot)de> writes:
> > We think, you wanted to switch to DESC behavior
> > (print out NULLS FIRST) in cases, where
> > „USING“ uses an operator which is considered to be
> > a DESC operator.
>
> Right, because that's how addTargetToSortList() would parse it.
>
> > But get_equality_op_for_ordering_op is called in
> > cases, where reverse is false, but
> > the part
> > if (reverse)
> > *reverse = (strategy == BTGreaterStrategyNumber);
> > never changes this to true?
>
> Sorry, not following? It's true that what I added to explain.c doesn't
> worry too much about the possibility of get_ordering_op_properties()
> failing --- that really shouldn't happen for something that was previously
> accepted as a sorting operator. But if it does, "reverse" will just be
> left as false, so the behavior will anyway be unsurprising I think.
> We could alternatively make it throw a "cache lookup failed" error but
> I'm not sure how that makes anyone's life better.
>
> regards, tom lane
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>