Re: half the query time in an unnecessary(?) sort? - Mailing list pgsql-performance

From Josh Berkus
Subject Re: half the query time in an unnecessary(?) sort?
Date
Msg-id 200504251511.41949.josh@agliodbs.com
Whole thread Raw
In response to half the query time in an unnecessary(?) sort?  (Ron Mayer <rm_pg@cheapcomplexdevices.com>)
Responses Re: half the query time in an unnecessary(?) sort?  (Ron Mayer <rm_pg@cheapcomplexdevices.com>)
List pgsql-performance
Ron,

> If I have a freshly CLUSTERed table and queries that want to do a
> merge join, it seems to me that quite a bit of time is spent
> unnecessarily sorting the already-sorted table. An example such
> query I found in my log files is shown below. If I read the
> EXPLAIN ANALYZE output correctly, it's saying that roughly half
> the time (570-269 = 300 out of 670 ms) was spent sorting the
> already sorted data.

It still has to sort because the clustering isn't guarenteed to be 100%.
However, such sorts should be very quick as they have little work to do.

Looking at your analyze, though, I think it's not the sort that's taking the
time as it is that the full sorted entity_id column won't fit in work_mem.
Try increasing it?


--
--Josh

Josh Berkus
Aglio Database Solutions
San Francisco

pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: [HACKERS] Bad n_distinct estimation; hacks suggested?
Next
From: "Dave Held"
Date:
Subject: Re: [HACKERS] Bad n_distinct estimation; hacks suggested?