Re: Why is sorting on two columns so slower thansortingon one column? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Why is sorting on two columns so slower thansortingon one column?
Date
Msg-id 23613.1293118017@sss.pgh.pa.us
Whole thread Raw
In response to Re: Why is sorting on two columns so slower thansortingon one column?  (Kenneth Marshall <ktm@rice.edu>)
Responses Re: Why is sorting on two columns so slower thansortingon one column?  (Jie Li <jay23jack@gmail.com>)
List pgsql-hackers
Kenneth Marshall <ktm@rice.edu> writes:
> On Thu, Dec 23, 2010 at 10:42:26PM +0800, Li Jie wrote:
>> But in the last query that sorts on "id",  since the query selects all the columns for output, the actual sorted
sizeis the same, and the only difference is the comparison cost. The query sorting on two columns needs to do twice the
comparison.Am I right?
 

> I think you are right. Sorry for the confusion.

I doubt the cost of comparing two integers is the issue here; rather
it's more likely one of how many merge passes were needed.  You could
find out instead of just speculating by turning on trace_sort and
comparing the log outputs.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Quan Zongliang
Date:
Subject: Re: Patch BUG #5103: "pg_ctl -w (re)start" fails with custom unix_socket_directory
Next
From: Robert Haas
Date:
Subject: Re: Streaming replication as a separate permissions