Lists: | pgsql-hackers |
---|
From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | is a special cost for external sort? |
Date: | 2013-07-18 16:14:41 |
Message-ID: | CAFj8pRDNJwkJxHGNrFR_+kBB7DPt_MwgUfx8gwMRAkqwny=1BA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hello
I found a slow query with large external sort. I expect, so external
sort should be penalized. Is it?
Regards
Pavel
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: is a special cost for external sort? |
Date: | 2013-07-18 18:53:03 |
Message-ID: | 5024.1374173583@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> writes:
> I found a slow query with large external sort. I expect, so external
> sort should be penalized. Is it?
See cost_sort() in src/backend/optimizer/path/costsize.c
regards, tom lane
From: | Jeff Janes <jeff(dot)janes(at)gmail(dot)com> |
---|---|
To: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: is a special cost for external sort? |
Date: | 2013-07-18 22:30:20 |
Message-ID: | CAMkU=1y4+ei780uVBWAnVNad_xAmi5viZBudVax6kzBk4-RVmQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Thu, Jul 18, 2013 at 9:14 AM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
> Hello
>
> I found a slow query with large external sort. I expect, so external
> sort should be penalized. Is it?
It tries to, but it doesn't seem to be much good at it. In
particular, I think it does a poor job of estimating the CPU cost of
an external sort relative to an in-memory sort of a slightly smaller
data set. In my experience adding the single tuple that actually
pushes you over the work_mem limit costs about 3x in CPU.
It is one of those things I started looking into a few times, but
never got anywhere before getting distracted.
Cheers,
Jeff