Return-Path: postarch
Received: by postgres.Berkeley.EDU (5.61/1.29)
	id AA04823; Thu, 2 Jul 92 23:18:40 -0700
Message-Id: <9207030618.AA04823@postgres.Berkeley.EDU>
From: postarch (Postgres Mailing Archive)
Subject: Re: Join Algorithms
To: postgres@postgres.berkeley.edu
Sender: pg_adm@postgres.berkeley.edu
In-Reply-To: Your message of "Thu, 02 Jul 92 22:37:19 PDT."
             <9207030537.AA04425@postgres.Berkeley.EDU> 
Date: Thu, 02 Jul 92 23:18:32 PDT


you write:
> 
> When does postgres choose hashjoin algorithm to do join operation? Is there
> any way to force postgres to do hashjoin rather then nested loop and sort-
> marge join? I would appreciate your response.
> 
> --Shengsong Ni

the postgres optimizer has a cost function for each join method and will
choose the one with minimum cost.  in general, if you don't have any indices
on the join attributes, hashjoin is the best join method, otherwise,
nestloop or mergejoin may be better.

if you run the postgres backend directly, you can use the -f option to
forbid a certain join method.  for example if you want to force hashjoin,
you say, "postgres -f nestloop -f mergejoin dbname".  if you want to run
from the monitor, refer to a previous mail sent out by jeff about how to
specify backend options from the postmaster.

-- wei
