Re: trying to study how sorting works

From: Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>
To: hitesh ramani <hiteshramani(at)hotmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: trying to study how sorting works
Date: 2015-03-27 05:51:09
Message-ID: CAFjFpRdTTCQBi4yiA51eSvyZQ1aHgsW8M2yuE6-JmWyP1YucXA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Mar 26, 2015 at 10:44 PM, hitesh ramani <hiteshramani(at)hotmail(dot)com>
wrote:

> Hello devs,
>
> I'm trying to understand how sorting exactly works in Postgres, I've
> understood that there are two sorting mechanisms depending on the size of
> the data, one being qsort which is initiated if workmem is < 1024 kb and
> the other being external sort which is initiated in the other case. I tried
> to find out more material to understand how it exactly works but I'm unable
> to find any help material.
>
>
Jim has answered this already.

> Moreover, I'm trying to study the code using gdb by attaching it to the
> pg_backend_pid and having a breakpoint at raw_parser, from where I start
> analyzing. Any help material or resources would be really appreciated.
>
>
In case of sort specifically, fire a query with an ORDER BY and break at
ExecSort. Step through this function and its minions. Try range of sizes of
results i.e. size of row * number of rows to understand the dynamics.

> Thanks.
>
> --Hitesh
>

--
Best Wishes,
Ashutosh Bapat
EnterpriseDB Corporation
The Postgres Database Company

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2015-03-27 06:34:19 Re: Parallel Seq Scan
Previous Message Kyotaro HORIGUCHI 2015-03-27 04:54:13 Re: Error with index on unlogged table