Subject: Join Algorithms

From: [email-masked] (Postgres Account)
Date: Thu, 2 Jul 92 22:37:19 -0700

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

---

From: postarch (Postgres Mailing Archive)
Date: Thu, 02 Jul 92 23:18:32 PDT

> marge join? I would appreciate your response.

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