Re: Poor performance o

Craig A. James <cjames@modgraph-usa.com>

From: "Craig A. James" <cjames@modgraph-usa.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-performance@postgresql.org
Date: 2006-03-22T01:04:16Z
Lists: pgsql-hackers, pgsql-performance
Tom Lane wrote:
> "Craig A. James" <cjames@modgraph-usa.com> writes:
>> It looks to me like the problem is the use of nested loops when a hash
>> join should be used, but I'm no expert at query planning.
> 
> Given the sizes of the tables involved, you'd likely have to boost up
> work_mem before the planner would consider a hash join.  What nondefault
> configuration settings do you have, anyway?

shared_buffers = 20000
work_mem = 32768
effective_cache_size = 300000

This is on a 4GB machine.  Is there a guideline for work_mem that's related to table size?  Something like, "allow 2 MB per million rows"?

I'm also curious why the big difference between my "Query #1" and "Query #2".  Even though it does a nested loop, #2's outer loop only returns one result from a very tiny table, so shouldn't it be virtually indistinguishable from #1?

Thanks,
Craig