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 ---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq