Re: further explain changes

Lists: pgsql-hackers
From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: further explain changes
Date: 2010-01-24 03:08:02
Message-ID: 603c8f071001231908u34129540h8c8a3a15d98d7e35@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Per recent discussion on pgsql-performance, and per discussion on
-hackers that it might not be too late for small patches after all,
here is a patch (as yet without documentation) which adds some
additional instrumentation to EXPLAIN for hashes: number of buckets,
number of batches, original number of batches, and peak memory
utilization. Thoughts?

I was also thinking about the possibility of adding a new option
called "output" and making that control whether the "Output" line gets
printed. It's kind of annoying to use EXPLAIN (ANALYZE, VERBOSE)
right now (and moreso with this patch) specifically because of that
line, which is quite... verbose. If we're going to change it ever we
should do it for 9.0, since we've made a lot of other changes that
people will be adjusting for anyhow.

Also, do we want to change the schema URL? The existing URL was
suggested by Peter but IIRC there was some thought that it might not
be the best choice.

http://www.postgresql.org/2009/explain

...Robert

Attachment Content-Type Size
explain-hash.patch text/x-patch 4.8 KB

From: Jaime Casanova <jcasanov(at)systemguards(dot)com(dot)ec>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: further explain changes
Date: 2010-01-24 05:06:38
Message-ID: 3073cc9b1001232106h5182ew14da1aea7ecc4456@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, Jan 23, 2010 at 10:08 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>
> I was also thinking about the possibility of adding a new option
> called "output" and making that control whether the "Output" line gets
> printed.  It's kind of annoying to use EXPLAIN (ANALYZE, VERBOSE)

why not let it go in ANALYZE, just as the sort info

--
Atentamente,
Jaime Casanova
Soporte y capacitación de PostgreSQL
Asesoría y desarrollo de sistemas
Guayaquil - Ecuador
Cel. +59387171157


From: Guillaume Lelarge <guillaume(at)lelarge(dot)info>
To: Jaime Casanova <jcasanov(at)systemguards(dot)com(dot)ec>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: further explain changes
Date: 2010-01-24 08:04:29
Message-ID: 4B5BFF0D.7050606@lelarge.info
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Le 24/01/2010 06:06, Jaime Casanova a écrit :
> On Sat, Jan 23, 2010 at 10:08 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>>
>> I was also thinking about the possibility of adding a new option
>> called "output" and making that control whether the "Output" line gets
>> printed. It's kind of annoying to use EXPLAIN (ANALYZE, VERBOSE)
>
> why not let it go in ANALYZE, just as the sort info
>

Yes, it would be more consistent. Other than that, this patch is quite
interesting.

--
Guillaume.
http://www.postgresqlfr.org
http://dalibo.com


From: Greg Stark <stark(at)mit(dot)edu>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: further explain changes
Date: 2010-01-24 11:22:55
Message-ID: 407d949e1001240322h418499abm803485439c0b727c@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

isn't that line pretty much the main point of "verbose"? I would assume
anything new like this would get its own option which might default to on.

greg

On 24 Jan 2010 03:08, "Robert Haas" <robertmhaas(at)gmail(dot)com> wrote:

Per recent discussion on pgsql-performance, and per discussion on
-hackers that it might not be too late for small patches after all,
here is a patch (as yet without documentation) which adds some
additional instrumentation to EXPLAIN for hashes: number of buckets,
number of batches, original number of batches, and peak memory
utilization. Thoughts?

I was also thinking about the possibility of adding a new option
called "output" and making that control whether the "Output" line gets
printed. It's kind of annoying to use EXPLAIN (ANALYZE, VERBOSE)
right now (and moreso with this patch) specifically because of that
line, which is quite... verbose. If we're going to change it ever we
should do it for 9.0, since we've made a lot of other changes that
people will be adjusting for anyhow.

Also, do we want to change the schema URL? The existing URL was
suggested by Peter but IIRC there was some thought that it might not
be the best choice.

http://www.postgresql.org/2009/explain

...Robert

--
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


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Jaime Casanova <jcasanov(at)systemguards(dot)com(dot)ec>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: further explain changes
Date: 2010-01-24 12:45:18
Message-ID: 603c8f071001240445k3443f30aqaf0bdbee822ebbac@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sun, Jan 24, 2010 at 12:06 AM, Jaime Casanova
<jcasanov(at)systemguards(dot)com(dot)ec> wrote:
> On Sat, Jan 23, 2010 at 10:08 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>>
>> I was also thinking about the possibility of adding a new option
>> called "output" and making that control whether the "Output" line gets
>> printed.  It's kind of annoying to use EXPLAIN (ANALYZE, VERBOSE)
>
> why not let it go in ANALYZE, just as the sort info

It's kinda long-winded - it adds like 4 extra lines for each hash
join. I don't think I want to add that much clutter to regular E-A
output.

If people don't like making it controlled by VERBOSE, then I vote for
a new option, as Greg Stark suggested.

...Robert


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Jaime Casanova <jcasanov(at)systemguards(dot)com(dot)ec>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: further explain changes
Date: 2010-01-24 17:30:26
Message-ID: 27825.1264354226@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> On Sun, Jan 24, 2010 at 12:06 AM, Jaime Casanova
>> why not let it go in ANALYZE, just as the sort info

> It's kinda long-winded - it adds like 4 extra lines for each hash
> join. I don't think I want to add that much clutter to regular E-A
> output.

Well, that would only happen if you're deliberately obtuse about the
formatting. The sort code manages to fit all the extra on one line,
and I don't see why hash couldn't.

I'd vote for just adding it in the exact same cases that sort adds extra
info. -1 for either adding a new option or changing the meaning of the
ones that are there.

regards, tom lane


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Jaime Casanova <jcasanov(at)systemguards(dot)com(dot)ec>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: further explain changes
Date: 2010-01-24 21:04:35
Message-ID: 603c8f071001241304n32ca3a44kc196c849113c07f8@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sun, Jan 24, 2010 at 12:30 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>> On Sun, Jan 24, 2010 at 12:06 AM, Jaime Casanova
>>> why not let it go in ANALYZE, just as the sort info
>
>> It's kinda long-winded - it adds like 4 extra lines for each hash
>> join.  I don't think I want to add that much clutter to regular E-A
>> output.
>
> Well, that would only happen if you're deliberately obtuse about the
> formatting.  The sort code manages to fit all the extra on one line,
> and I don't see why hash couldn't.
>
> I'd vote for just adding it in the exact same cases that sort adds extra
> info.  -1 for either adding a new option or changing the meaning of the
> ones that are there.

Care to suggest a format?

...Robert


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Jaime Casanova <jcasanov(at)systemguards(dot)com(dot)ec>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: further explain changes
Date: 2010-01-24 21:24:35
Message-ID: 19927.1264368275@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> Care to suggest a format?

As much like the sort case as possible ...

regards, tom lane


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Jaime Casanova <jcasanov(at)systemguards(dot)com(dot)ec>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: further explain changes
Date: 2010-01-28 21:18:59
Message-ID: 603c8f071001281318i40e66d6crd55bc1eb6beb1d4a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sun, Jan 24, 2010 at 12:30 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>> On Sun, Jan 24, 2010 at 12:06 AM, Jaime Casanova
>>> why not let it go in ANALYZE, just as the sort info
>
>> It's kinda long-winded - it adds like 4 extra lines for each hash
>> join.  I don't think I want to add that much clutter to regular E-A
>> output.
>
> Well, that would only happen if you're deliberately obtuse about the
> formatting.  The sort code manages to fit all the extra on one line,
> and I don't see why hash couldn't.

OK, here's a new version.

...Robert

Attachment Content-Type Size
explain-hash-v2.patch text/x-patch 4.8 KB

From: Jaime Casanova <jcasanov(at)systemguards(dot)com(dot)ec>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: further explain changes
Date: 2010-01-30 17:26:41
Message-ID: 3073cc9b1001300926h2845f6d5p75f4c70a222ba8e8@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Jan 28, 2010 at 4:18 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> On Sun, Jan 24, 2010 at 12:30 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>>> On Sun, Jan 24, 2010 at 12:06 AM, Jaime Casanova
>>>> why not let it go in ANALYZE, just as the sort info
>>
>>> It's kinda long-winded - it adds like 4 extra lines for each hash
>>> join.  I don't think I want to add that much clutter to regular E-A
>>> output.
>>
>> Well, that would only happen if you're deliberately obtuse about the
>> formatting.  The sort code manages to fit all the extra on one line,
>> and I don't see why hash couldn't.
>
> OK, here's a new version.
>

OK, i have 3 hashes in a query and i got these 3 lines in an EXPLAIN
ANALYZE with your patch
"""
-> Hash (cost=3878.94..3878.94 rows=83594
width=34) (actual time=504.648..504.648 rows=83594 loops=1)
Buckets: 2048 Batches: 8 Memory Usage: 589kB
[...]
-> Hash (cost=14.49..14.49 rows=649 width=15)
(actual time=2.901..2.901 rows=649 loops=1)
Buckets: 1024 Batches: 1 Memory Usage: 32kB
[...]
-> Hash (cost=977.62..977.62 rows=6555 width=16)
(actual time=60.913..60.913 rows=6556 loops=1)
Buckets: 1024 Batches: 1 Memory Usage: 308kB
"""

I guess Memory Usage is per Batch, right? is this an average?
What is the unit measure for Bucket?
there are 14 temp files generated for this query and the only Sort
says it was on memory so these files should come from the hashes, can
we say that in the explain analyze? mmm... that memory usage, could be
Disk actually?

--
Atentamente,
Jaime Casanova
Soporte y capacitación de PostgreSQL
Asesoría y desarrollo de sistemas
Guayaquil - Ecuador
Cel. +59387171157


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Jaime Casanova <jcasanov(at)systemguards(dot)com(dot)ec>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: further explain changes
Date: 2010-01-31 05:27:27
Message-ID: 603c8f071001302127j27c843bdnce8ea27a5dc56412@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, Jan 30, 2010 at 12:26 PM, Jaime Casanova
<jcasanov(at)systemguards(dot)com(dot)ec> wrote:
> On Thu, Jan 28, 2010 at 4:18 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>> On Sun, Jan 24, 2010 at 12:30 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>>>> On Sun, Jan 24, 2010 at 12:06 AM, Jaime Casanova
>>>>> why not let it go in ANALYZE, just as the sort info
>>>
>>>> It's kinda long-winded - it adds like 4 extra lines for each hash
>>>> join.  I don't think I want to add that much clutter to regular E-A
>>>> output.
>>>
>>> Well, that would only happen if you're deliberately obtuse about the
>>> formatting.  The sort code manages to fit all the extra on one line,
>>> and I don't see why hash couldn't.
>>
>> OK, here's a new version.
>>
>
> OK, i have 3 hashes in a query and i got these 3 lines in an EXPLAIN
> ANALYZE with your patch
> """
>                        ->  Hash  (cost=3878.94..3878.94 rows=83594
> width=34) (actual time=504.648..504.648 rows=83594 loops=1)
>                                 Buckets: 2048  Batches: 8  Memory Usage: 589kB
> [...]
>                     ->  Hash  (cost=14.49..14.49 rows=649 width=15)
> (actual time=2.901..2.901 rows=649 loops=1)
>                           Buckets: 1024  Batches: 1  Memory Usage: 32kB
> [...]
>               ->  Hash  (cost=977.62..977.62 rows=6555 width=16)
> (actual time=60.913..60.913 rows=6556 loops=1)
>                     Buckets: 1024  Batches: 1  Memory Usage: 308kB
> """
>
> I guess Memory Usage is per Batch, right? is this an average?

It's the maximum memory every used by that hash.

> What is the unit measure for Bucket?

There is no unit - it's just how many buckets.

> there are 14 temp files generated for this query and the only Sort
> says it was on memory so these files should come from the hashes, can
> we say that in the explain analyze?

I think maybe it's 2 temp files per batch in excess of 1, thus (8 - 1)
x 2 = 14 for the 8-batch join and none for the other two. Perhaps
you'd care to test that hypothesis?

> mmm... that memory usage, could be
> Disk actually?

No.

...Robert