On Mon, 2007-06-25 at 17:56 -0400, Stephen Frost wrote: > Was the 'work_mem' set to the same thing on all these runs? Also, you > might try increasing the 'work_mem' under 8.2.4, at least for this query > (you can set it by just doing: set work_mem = '2GB'; or similar in psql, > or you can change the default in postgresql.conf). > > The big thing of note, it seems, is that you've got enough memory and > it's coming out faster when doing a hash-join vs. a sort + merge-join. > Could likely be because it doesn't think there's enough work memory > available for the hash, which might change based on the values it gets > from the statistics on how frequently something shows up, etc. > > Enjoy, > > Stephen Yes, work_mem was set to 128MB for all runs. All settings were the same except for the change to default_statistics_target. I'm certainly memory constrained, but giving 2GB to one one session doesn't allow other sessions to do anything. Possibly when we upgrade to 16GB. :-)