agora inbox for postgres@postgres.berkeley.edu  
help / color / mirror / Atom feed
From: Paul M. Aoki <aoki@CS.Berkeley.EDU>
To: Pei Cao <pc@cs.Princeton.EDU>
Cc: postgres@postgres.Berkeley.EDU
Subject: Re: how is a three-way join implemented?
Date: Sat, 06 Aug 94 15:56:26 -0700
Message-ID: <199408062256.PAA09874@nobozo.CS.Berkeley.EDU> (raw)
In-Reply-To: <9408062242.AA17476@cs>

Pei Cao <pc@cs.Princeton.EDU> writes:
> Does Postgres join small and large1 first, then join the result relation with 
> large2?  Or does it join all three of them together at the same time, if so,
> how exactly does it do that?

join strategies are determined by a conventional dynamic programming
query optimizer patterned after the system r optimizer.

%A P. G. Selinger
%A M. M. Astrahan
%A D. D. Chamberlin
%A R. A. Lorie
%A T. G. Price
%T Access Path Selection in a Relational Database Management System
%J PROC 1979 SIGMOD
%C Boston, MA
%D JUN 1979
%K system r optimizer
%P 23-34

query plans are (generally speaking) left-deep binary trees; no more
than two tables are joined in a single join operation, though of course
more than one join can be going on at once.

you can dump query plans using the -d flag to "postmaster" and 
"postgres".  the format isn't documented but you can probably figure 
out what's going on.

note that catalog statistics (on which the optimizer must rely for
its cost formulae) are only updated if you run vacuum (all tables)
or build an index (just that one table).
--
  Paul M. Aoki          |  University of California at Berkeley
  aoki@CS.Berkeley.EDU  |  Dept. of EECS, Computer Science Division (#1776) 
                        |  Berkeley, CA 94720-1776

==============================================================================
   To add/remove yourself to/from the POSTGRES mailing list: send mail with 
   the subject line ADD or DEL to "postgres-request@postgres.Berkeley.EDU"

   If this fails, send mail to "post_questions@postgres.Berkeley.EDU" and
   a human will deal with it.  DO NOT post to the "postgres" mailing list.
==============================================================================



reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: postgres@postgres.berkeley.edu
  Cc: aoki@CS.Berkeley.EDU, pc@cs.Princeton.EDU
  Subject: Re: how is a three-way join implemented?
  In-Reply-To: <199408062256.PAA09874@nobozo.CS.Berkeley.EDU>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox