| From: | Josh Berkus <josh(at)agliodbs(dot)com> | 
|---|---|
| To: | Ron Mayer <rm_pg(at)cheapcomplexdevices(dot)com> | 
| Cc: | pgsql-performance(at)postgresql(dot)org | 
| Subject: | Re: half the query time in an unnecessary(?) sort? | 
| Date: | 2005-04-25 22:11:41 | 
| Message-ID: | 200504251511.41949.josh@agliodbs.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Dave Held | 2005-04-25 22:41:41 | Re: [HACKERS] Bad n_distinct estimation; hacks suggested? | 
| Previous Message | Christopher Browne | 2005-04-25 22:03:52 | Re: Joel's Performance Issues WAS : Opteron vs Xeon |